pawel-brzezinski / smart-cache-component
支持PSR-6和外部缓存库作为提供者的缓存组件
dev-master
2019-02-19 16:26 UTC
Requires
- php: ^7.1
- psr/cache: ^1.0
Requires (Dev)
- phpunit/phpunit: ^7.5
- symfony/cache: ^4.2
This package is auto-updated.
Last update: 2024-09-20 05:38:07 UTC
README
PSR-16缓存组件,用于包装其他外部缓存库。它为您提供了在应用程序中轻松更改缓存库的机会。
安装
通过Composer下载SmartCache组件
composer require pawel-brzezinski/smart-cache-component
支持的缓存库
缓存标签
SmartCache组件为支持标签的库提供了缓存项标签方法和缓存池。
示例
标签缓存项
$cacheItem1 = $cache->getItem('foo');
$cacheItem1->setTags(['tag1', 'tag2']);
$cacheItem2 = $cache->getItem('bar');
$cacheItem2->setTags(['tag2', 'tag3']);
$cache->save($cacheItem1);
$cache->save($cacheItem2);
通过缓存标签使缓存失效
// All cache keys tagged by "tag2" tag will be invalidated
$cache->invalidateTags(['tag2']);