crazymeeks / phpcacher
PHP 缓存库
dev-master
2017-08-13 05:36 UTC
Requires
- predis/predis: ^1.1
Requires (Dev)
- phpunit/phpunit: 4.0.*
This package is not auto-updated.
Last update: 2024-09-18 19:17:36 UTC
README
phpcacher
关于
PHP 缓存库
- v1.0.0
要求
- PHP >= 5.6.*
支持的驱动程序
- 文件
- apcu v4.0.8
如何安装
- 在你的 composer.json 文件中添加此 require 键
"require": {
"crazymeeks/phpcacher": "v1.0.0"
}
- 使用 CLI 命令,复制并在目标项目或指定文件夹中执行此命令
composer require crazymeeks/phpcacher
如何使用
<?php
require __DIR__ . '/vendor/autoload.php';
use Crazymeeks\PHPCacher\Cacher;
$cache = new Cacher;
$instance = $cache->setDriver('files');
$data = array('id' => 1, 'name' => 'John Doe');
Store data to cache and expires in 1hr
$data = array('name' => 'John Doe');
$instance->setKey('user')->setItem($data)->expires(3600);
Get Item in the cache
$item = $instance->getItem('user');
Print the item
print_r($item);
?>
设置自定义缓存目录
- 您也可以设置自己的缓存目录,其中缓存数据将被保存。
$instance->cache->setDriver('files', '/tmp/'); // For windows users, 'D:/cachetmp' or 'C:/cachetmp'
报告错误
作者
Jeff Claud[jeffclaud17@gmail.com]
贡献者
Aaron Tolentino[aarontolentino123@gmail.com]
Joshua Clifford Reyes
参考资料
- 请参阅 WIKI 以获取文档