fivepercent / cache
缓存系统
v1.0
2015-06-04 08:07 UTC
Requires
- php: >=5.4
This package is not auto-updated.
Last update: 2024-09-28 17:43:48 UTC
README
使用此包,您可以在任何存储中缓存任何数据。
安装
在您的 composer.json 中添加 FivePercent/Cache
{ "require": { "fivepercent/cache": "~1.0" } }
现在运行以下命令告诉 composer 下载库:
$ php composer.phar update fivepercent/cache
基本用法
可用存储
- ArrayCache
- 在内部数组中缓存数据。脚本结束后将被销毁。
- RedisCache
- 在 Redis 存储中缓存数据。数据以 HASH 类型存储。
- ChainCache
- NullCache
示例
use FivePercent\Component\Cache\ArrayCache; $cache = new ArrayCache(); if (!$cache->has('my_key')) { $cache->set('my_key', 'My Value'); } print $cache->get('my_key'); // Printing "My Value"
Symfony2
如果您使用 Symfony2 框架,您可以使用 CacheClearer 来清除缓存。
Symfony2 ExpressionLanguage
如果您使用 ExpressionLanguage(Symfony 组件),您可以使用 ParserCache 来存储 ExpressionLanguage 表达式。