graphstory/cache-interface

通用缓存接口

0.0.3 2015-11-20 17:37 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:25:27 UTC


README

基于Anthony Ferrara博客文章的简单缓存适配器和接口 对PHP-FIG公开信的后续跟进.

Build Status

安装

使用Composer

使用 Composer 安装cache-interface库

$ composer require graphstory/cache-interface

使用方法

// Example using Daniel González's Cache library

use Desarrolla2\Cache\Cache;
use Desarrolla2\Cache\Adapter\File;
use GraphStory\Console\Cache\DesarrollaAdapter;

$cacheDir = '/tmp';
$adapter = new File($cacheDir);
$adapter->setOption('ttl', 3600);
$desarrolla2 = new Cache($adapter);
$cache = DesarrollaAdapter($desarrolla2);

$cache->set('key', 'myKeyValue', 3600);

// later ...

echo $cache->get('key');

(以上示例大部分来自 desarrolla2/Cache 文档.)

BYOA (自带适配器)

您可以通过创建一个实现 CacheAdapter 接口的类来自定义适配器。以其他适配器为参考,您应该可以顺利完成任务!