mirror of
https://github.com/kevin-DL/scraps.git
synced 2026-01-11 18:04:31 +00:00
Set request caching
This commit is contained in:
@@ -2,11 +2,18 @@
|
||||
|
||||
namespace App\Http\Integrations\Spoonacular\Requests;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Saloon\CachePlugin\Contracts\Cacheable;
|
||||
use Saloon\CachePlugin\Contracts\Driver;
|
||||
use Saloon\CachePlugin\Drivers\LaravelCacheDriver;
|
||||
use Saloon\CachePlugin\Traits\HasCaching;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
|
||||
class FindRecipesByIngredients extends Request
|
||||
class FindRecipesByIngredients extends Request implements Cacheable
|
||||
{
|
||||
use HasCaching;
|
||||
|
||||
/**
|
||||
* The HTTP method of the request
|
||||
*/
|
||||
@@ -36,4 +43,14 @@ class FindRecipesByIngredients extends Request
|
||||
'number' => $this->number,
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveCacheDriver(): Driver
|
||||
{
|
||||
return new LaravelCacheDriver(Cache::store('redis'));
|
||||
}
|
||||
|
||||
public function cacheExpiryInSeconds(): int
|
||||
{
|
||||
return 3600;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user