keepeye / cache
好用的PHP缓存类库
1.0
2015-05-08 06:05 UTC
Requires
- php: >=5.3
This package is not auto-updated.
Last update: 2024-09-28 17:59:58 UTC
README
这是一个简单的PHP缓存库。
它支持不同的驱动程序。
基本用法
-
通过
composer
安装composer require keepeye/cache
-
查看
<?php include "vendor/autoload.php"; //first you should make a instance of cacheManager $cacheManager = new Keepeye\Cache\Cache; //get a instance of driver through cacheManager with some options $cache = $cacheManager->getInstance(array( "dir" => __DIR__."/cache" )); //store an item in the cache for 600 seconds. $cache->put("k1","v1",600); //retrieve an item by key $cache->get("k1");//output "v1" //remove an item $cache->forget("k1"); $cache->get("k1");//get null //remove all $cache->fush();
高级用法
-
文件驱动程序
此驱动程序基于文件系统。它有以下几个选项
- **dir** where the cache files stored in. - **depth** cache dir depth,default 2
-
其他驱动程序
未来还将支持一些其他驱动程序,例如redis、mysql、sqlite等。
测试
您应该已安装phpunit。然后进入目录,执行:
composer install
phpunit
许可证
此库是开源软件,许可协议为MIT许可证