laminas/laminas-cache-storage-adapter-memcached
Memcached storage adapter for Laminas Cache. Provides a cache storage implementation backed by the PHP Memcached extension, supporting common cache operations, options, and integration with Laminas cache plugins and configuration.
StorageInterface, ensuring backward compatibility with Laravel’s Cache::extend() and Cache::store() methods.Cache::extend() method remains the primary entry point.Cache::extend('memcached', function ($app) {
$memcached = new \Memcached();
$memcached->addServer('localhost', 11211);
return \Laminas\Cache\Storage\Adapter\Memcached::factory([
'memcached' => $memcached,
'namespace' => 'laravel_',
]);
});
2.x or 3.x can upgrade without code modifications.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| PHP Version Support | New: Officially supports PHP 8.4 (previously untested). | Test thoroughly in staging; monitor for edge cases (e.g., typed properties). |
| BC Breaks | None in this release; 3.1.0 is a minor update. |
Safe to upgrade from 3.0.x; no migration steps required. |
| Performance Overhead | Unchanged; Memcached’s network latency remains (~1-10ms per op). | Benchmark against Redis/APCu; optimize memcached server configuration. |
| Key Length Limits | Still enforced (250-byte keys). | Monitor key collisions; adjust namespace if needed. |
| Connection Handling | Manual server management remains required. | Use MemcachedResourceManager for dynamic scaling. |
3.0.x instead.)memcached → file) be tested?queue:work).Cache::remember() and middleware (e.g., Cache::tags()).| Laravel Version | PHP Version | Recommended Adapter Version | Notes |
|---|---|---|---|
| 11.x | 8.4 | 3.1.0 | Full PHP 8.4 support. |
| 10.x | 8.1–8.3 | 3.1.0 | Safe upgrade; no BC breaks. |
| 9.x | 8.0 | 2.x | Avoid 3.x if PHP < 8.1. |
config, views).config/cache.php):
'stores' => [
'memcached' => [
'driver' => 'memcached',
'servers' => [['host' => 'memcached', 'port' => 11211]],
'options' => [
'namespace' => 'laravel_',
],
],
],
Cache::extend('memcached_fallback', function ($app) {
return Cache::store('memcached')->extend(function ($cache) {
return new class($cache) implements CacheStoreContract {
public function get($key, $default = null) {
try {
return $cache->get($key, $default);
} catch (\Exception $e) {
return Cache::store('file')->get($key, $default);
}
}
// ... other methods
};
});
});
tags option.Cache::dispatcher() (PSR-16).queue:work.increment) depend on Memcached’s add/cas (not all Laminas methods expose these).composer.json:
"require": {
"laminas/laminas-cache-storage-adapter-memcached": "^3.1",
"ext-memcached": "*"
}
AppServiceProvider (unchanged from previous version).k6) to validate performance under PHP 8.4.memcached_client_gets_total).laminas/laminas-cache and ext-memcached for security patches.3.0.x → 3.1.0 (minor, safe).namespace to avoid collisions.3.1.0 focuses on PHP 8.4 support.Xdebug or error_log if edge cases arise.memcached->getResultCode() to diagnose connection issues.How can I help you explore Laravel packages today?