seworqs/commons-cache
最新稳定版本:2.0.0
Composer 安装命令:
composer require seworqs/commons-cache
包简介
A lightweight PSR-16 cache manager with multi-namespace support, configurable Symfony adapters, and TTL handling.
README 文档
README
A lightweight PSR-16 cache manager with multi-namespace support, configurable Symfony adapters, and TTL handling.
Built on top of symfony/cache, fully compatible with PHP 8.1+ and PSR standards.
Installation
composer require seworqs/commons-cache
Basic Usage (stand-alone)
use Seworqs\Commons\Cache\CacheManagerFactory; $config = [ 'namespaces' => [ 'default' => [ 'adapter' => 'array', 'ttl' => 3600, ], 'menu' => [ 'adapter' => 'filesystem', 'ttl' => 600, 'directory' => __DIR__ . '/cache/menu', ], ], ]; $manager = CacheManagerFactory::create($config); $cache = $manager->getNamespace(); $cache->set('foo', 'bar'); $value = $cache->get('foo');
Adapter Options
You may use:
✅ Aliases:
'array''filesystem''null'
✅ Full class names:
'adapter' => Symfony\Component\Cache\Adapter\PhpFilesAdapter::class
✅ Ready-to-use instances:
'adapter' => new Symfony\Component\Cache\Adapter\RedisAdapter($redisClient, 'namespace', 600)
Other adapters like Redis, Memcached, or PDO can be used by providing their full class name and handling construction yourself.
Laminas Integration
'factories' => [ Seworqs\Commons\Cache\CacheManagerInterface::class => Seworqs\Commons\Cache\CacheManagerFactory::class, ],
Use via dependency injection:
public function __construct(private CacheManagerInterface $cacheManager) {}
Testing
composer test
Runs PHPUnit using in-memory adapters.
License
Apache-2.0, see LICENSE
About SEworqs
Seworqs builds clean, reusable modules for PHP and Mendix developers.
Learn more at github.com/seworqs
Badges
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2025-05-19