cache/redis-adapter
PSR-6 cache pool backed by Redis using the PhpRedis extension. Part of the PHP Cache ecosystem, with shared docs for advanced features like tagging and hierarchy. Supports Redis, RedisArray, and RedisCluster clients.
Cache facade, Cache::tags(), and other PSR-6-compatible components (e.g., symfony/cache). Eliminates vendor lock-in by adhering to a PHP-FIG standard.file/database drivers).Cache::remember()).dispatch() outputs).user:123 caches when a profile updates). The adapter’s tagging mechanism (CacheItemPoolInterface) maps cleanly to Laravel’s Cache::tags() syntax.phpredis, which is already a Laravel dependency for Redis queues/sessions. Avoids introducing new extensions or infrastructure.config/cache.php). No core framework modifications required.file), ensuring graceful degradation if Redis fails. Example:
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
'fallback' => env('CACHE_FALLBACK', 'file'),
],
Cache::tags(['user', 'profile'])->clear() syntax out-of-the-box, reducing boilerplate for cache invalidation.phpredis extension (common in Laravel but may need installation in some environments). Risk mitigated if Redis is already used for other purposes.maxmemory-policy, timeouts) can degrade performance or cause evictions. The adapter inherits these risks from the underlying server.HSET/HGET for metadata, which adds minor overhead (~1–2ms per operation). Benchmark under production-like loads to validate impact.RedisCluster is supported, the adapter lacks built-in sharding logic. Multi-region deployments may require additional configuration (e.g., client-side sharding).maxmemory)? If not, what are the operational constraints (e.g., memory limits, backup policies)?Cache::tags(['product:*'])->clear())?user:123:profile, user:123:orders) that could stress Redis?file) if Redis is unavailable? What’s the SLA for cache availability?used_memory)?maxmemory is configured)?phpredis (security patches)?cache/redis-adapter (new features/bugfixes)?Cache facade (e.g., Cache::remember(), Cache::tags()).Cache::store('redis') for multi-driver setups.config/database.php).cache, database queues), avoiding duplicate infrastructure.symfony/cache), though this is secondary for Laravel-specific use cases.composer require cache/redis-adapter
config/cache.php to use the Redis driver:
'stores' => [
'redis' => [
'driver' => 'redis',
'connection' => 'cache', // Laravel's Redis connection
'prefix' => env('CACHE_PREFIX', 'laravel_redis_'),
'fallback' => env('CACHE_FALLBACK', null), // Optional
],
],
phpredis is installed (php -m | grep redis).Dockerfile or server config:
RUN docker-php-ext-install redis
Cache::tags() invalidation in a staging environment.Cache::tags(['user', 'profile'])->put('user:123:profile', $data);
Cache::tags(['user'])->clear(); // Should invalidate all user-tagged caches.
file, database) for:
Cache::get() response time).ab (Apache Benchmark) or Laravel’s bench() helper.symfony/cache).RedisCluster, but manual sharding may be needed for complex setups.phpredis 5.0+ (older versions may lack compatibility with newer Redis features).maxmemory-policy, timeout, persistence).maxmemory 1gb
maxmemory-policy allkeys-lru
timeout 300
cache:clear commands, non-session data).file/database drivers).file) handle critical paths gracefully.redis-cli INFO | grep -E 'used_memory|keyspace_hits|keyspace_misses'
used_memory > 80% of maxmemory).evicted_keys).cache/redis-adapter: Monitor for updates via Packagist or GitHub releases. Low maintenance burden (MIT license, active but infrequent updates).How can I help you explore Laravel packages today?