laminas/laminas-cache
Laminas Cache provides flexible caching for PHP apps with storage adapters (memory, filesystem, Redis, etc.), plugins, and cache patterns. Includes PSR-6/PSR-16 support, configuration options, and utilities for improving performance and reducing expensive operations.
Illuminate\Cache) is already PSR-16-compatible, but Laminas Cache offers additional features like:
Cache facade already supports PSR-16 adapters. Laminas Cache can be wrapped via SimpleCacheDecorator to integrate with Laravel’s Cache::store() system.
// Example: Register Laminas Cache as a Laravel store
Cache::extend('laminas', function ($app) {
$storage = (new StorageAdapterFactory())->create('redis', [
'host' => config('cache.redis.host'),
]);
return new SimpleCacheDecorator($storage);
});
config/cache.php can be extended to support Laminas-specific adapters (e.g., dba, memcache).Laminas\Cache\Storage\Plugin\Serializer or Laravel’s serialize/unserialize wrappers.DateInterval for TTLs, while Laravel uses seconds. Mitigation: Normalize TTLs in a service layer.serialize suffice, or is Laminas’ plugin system needed?SimpleCacheDecorator integrates seamlessly with Laravel’s Cache facade.$app->bind('laminas.cache', function ($app) {
return (new StorageAdapterFactory())->create('redis', [
'host' => config('cache.redis.host'),
]);
});
ModelDeleted → clear cache tags).predis/predis directly.symfony/cache may offer tighter integration.composer require laminas/laminas-cache laminas/laminas-cache-storage-adapter-redis
// config/cache.php
'stores' => [
'laminas' => [
'driver' => 'laminas',
'connection' => 'redis',
],
],
DateInterval TTLs).laminas/laminas-cache-storage-adapter-redis (Predis or PHPRedis).cache_dir is writable and configured in config/filesystems.php.laminas/laminas-cache-storage-adapter-memcached instead.SimpleCacheDecorator for PSR-16 compatibility.Serializer, ExceptionHandler) as needed.StorageInterface to test cache logic.predis/predis).config/cache.php or module-specific files..env) to switch adapters.composer.json during stabilization.$storage->setOption('logging', true);
ExceptionHandler plugin to log cache failures.Serializer for Filesystem).DateInterval vs. integer TTLs.cache_dir permissions (e.g., chmod -R 775 storage/cache).How can I help you explore Laravel packages today?