jejd14/ccache

用于缓存信息的简单类

安装: 5

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

语言:HTML

dev-master 2015-05-10 17:19 UTC

This package is not auto-updated.

Last update: 2024-10-02 09:11:00 UTC


README

Scrutinizer Code Quality Code Coverage Build Status License

CCache

关于

用于缓存信息的简单类

##技术

PHP >= 5.4.0
Tested on Anax MVC >= 2.0.4

简介

实例化 CCache 对象

$newCCache = new \jejd14\ccache\CCache($dir);

或者,在Anax 框架中将 CCache 对象作为共享服务实例化

$di->setShared('cache', function($dir) {
    $cache = new \jejd14\ccache\CCache($dir);
    return $cache;
});

方法

  1. __construct ($dir) - 构造函数
  2. get ($key) - 如果存在,则从缓存中获取一个项目。
  3. put ($key, $item) - 将一个项目放入缓存。
  4. prune($key) - 从缓存中移除一个项目。
  5. pruneAll() - 从缓存中移除所有项目。

方法调用

要正确使用上面列出的方法,您可以按照以下方式调用它(假设您已将服务作为共享服务设置在您的前端控制器中)

在一个扩展/implements/uses \Anax\DI\TInjectionAware 的类中

$this->di->cache->put('file','hello');

在您的前端控制器中

$app->cache->put('file','hello');

要移除缓存中的所有项目

$app->cache->pruneAll();

Composer

您可以将 ccache 添加到您的 composer.json 文件中,如下所示。

"require": {
  "jejd14/ccache": "dev-master"
 }

许可证

MIT