Set request caching

This commit is contained in:
2024-06-23 17:02:50 +01:00
parent 01002b31a7
commit 545743794a
3 changed files with 70 additions and 2 deletions

View File

@@ -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;
}
}