cache/memcached-adapter
PSR-6 cache pool backed by Memcached. Create a Memcached client, add servers, and use MemcachedCachePool for fast, standards-based caching. Part of the PHP Cache ecosystem with shared docs for tagging and hierarchy support.
FileCache, RedisCache). This ensures seamless integration with Laravel’s caching layer, including:
Cache::store('memcached') support (if configured via Laravel’s cache config).CacheItemPoolInterface).Cache facade if configured as a custom driver.ext-memcached (PHP extension) must be installed on the server.file or redis drivers).MEMSTATS equivalent).ext-memcached extension supported across our deployment environments (e.g., shared hosting, Docker)?array, file)?redis driver in terms of performance and cost?file or database cache for better speed.MemcachedSessionHandler alongside).composer.json:
composer require cache/memcached-adapter
config/cache.php:
'stores' => [
'memcached' => [
'driver' => 'memcached',
'servers' => [
['host' => 'memcached', 'port' => 11211, 'weight' => 100],
],
'options' => [
// Memcached-specific options (e.g., compression, retry logic)
'compression' => false,
'prefix' => 'laravel_',
],
],
],
memcached store in Laravel’s Cache facade:
Cache::store('memcached')->put('key', 'value', now()->addMinutes(10));
CacheItemPoolInterface:
$item = $pool->getItem('user:123');
$item->setTags(['user', 'profile']);
$pool->save($item);
Cache::store('memcached') behaves as expected.array or file cache).file or redis).Cache::driver('memcached')->rememberForever(...) with array fallback).INFO command).ext-memcached (must be kept updated).memcached-tool or telnet for basic checks.php artisan cache:clear won’t work for Memcached).memcached-tool stats to avoid evictions.addServer()).memcached server’s -m flag (e.g., -m 256 for 256MB).cache config can adjust options (e.g., compression_threshold).memtier_benchmark).spatie/laravel-queue-snapshot to test queue caching under load.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Memcached server down | Cache misses → degraded performance | Fallback to array or file cache. |
| Network partition | Timeouts on cache reads/writes | Implement |
How can I help you explore Laravel packages today?