bentools/cache
最新稳定版本:1.1
Composer 安装命令:
composer require bentools/cache
包简介
PSR-6 and PSR-16 Cache Adapters.
README 文档
README
bentools/cache
Usage
Cache Fallback
If calling a cache method throws an exception, it will fall back to the other cache pool.
use BenTools\Cache\Fallback\CacheFallback; use Cache\Adapter\Memcache\MemcacheCachePool; use Cache\Adapter\Redis\RedisCachePool; $main = new RedisCachePool(new Redis()); $default = new MemcacheCachePool(new Memcache()); $cache = new CacheFallback($main, $default); $cache->get('foo'); // if $main->get('foo') throws an exception, will call $default->get('foo')
You can use as many cache pools as you want, so that a failing cache falls back to the next healthy one:
use BenTools\Cache\Fallback\CacheFallback; use Cache\Adapter\Memcache\MemcacheCachePool; use Cache\Adapter\Redis\RedisCachePool; use Cache\Adapter\PHPArray\ArrayCachePool; $redis = new RedisCachePool(new Redis()); $memcache = new MemcacheCachePool(new Memcache()); $arrayCache = new ArrayCachePool(); $cache = new CacheFallback($redis, $memcache, $arrayCache); $cache->get('foo');
Installation
composer require bentools/cache
Tests
./vendor/bin/phpunit
License
MIT.
统计信息
- 总下载量: 2.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-15