saloonphp/cache-plugin
Laravel/PHP caching plugin for Saloon HTTP client. Cache API responses with configurable drivers, TTLs, and cache keys to reduce requests and speed up integrations. Supports per-request caching controls and easy setup for existing Saloon connectors.
saloonphp/cache-plugin is a specialized plugin for caching HTTP responses in Saloon, a PHP HTTP client library. It aligns well with architectures requiring response caching (e.g., rate-limited APIs, expensive endpoints, or read-heavy workloads).withCache() method or middleware hooks, requiring minimal code changes.php-cache/cache-item-pool, predis/predis for Redis).cache()->remember()).endpoint+queryParams)?/products)./user/profile).saloonphp/circuit-breaker) for cache failures.composer.json constraints).composer require saloonphp/cache-plugin predis/predis # Example with Redis
// Configure cache (e.g., Redis)
$cache = new PredisClient(['scheme' => 'tcp', 'host' => 'redis']);
Saloon::withCache($cache);
// Or per-request caching
$response = $request->withCache()->send();
$request->withCache()->withCacheKeyFn(fn () => 'custom_key_' . $request->endpoint);
$request->withCache()->send(); // Write operation
Cache::delete('key_for_' . $request->endpoint);
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Cache backend down | Fallback to uncached requests | Implement circuit breaker + alerts. |
| Stale cache data | Inconsistent user experience | Short TTL + cache invalidation hooks. |
| Key collision (cache misses) | Unexpected API calls | Unique key generation (e.g., include ETag). |
| Plugin bug (e.g., 2026 release) | Broken caching | Feature flags + rollback plan. |
| Network partition (distributed) | Split-brain cache state | Strong consistency (e.g., Redis Sentinel). |
How can I help you explore Laravel packages today?