yabx/cache
最新稳定版本:0.0.2
Composer 安装命令:
composer require yabx/cache
包简介
Simple Cache Implementation
README 文档
README
- CacheInterface (cache interface)
- FileCache (file cache implementation)
- RedisCache (Redis cache implementation)
Installation
composer req yabx/cache
Simple usage
<?php use Yabx\Cache\FileCache; use Yabx\Cache\RedisCache; // FileCache $cache = new FileCache(__DIR__ . '/cache'); // or RedisCache $redis = new Redis; $redis->connect('localhost'); $cache = new RedisCache($redis, 'prefix:'); // Setting value (3600 seconds live period) $cache->set('key', $value, 3600); // Getting value by key $value = $cache->get('key'); // Deleting value by key $cache->delete('key');
Example
<?php // .... $key = 'calculated'; // Checking for cached item with $key if(!$value = $cache->get($key)) { // Hardworking for calculate value $value = calc(....); $cache->set($key, $value, 3600); } // Displing value echo $value;
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-17