jejd14/ccache

A small class for caching information

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

This package is not auto-updated.

Last update: 2025-06-25 12:28:54 UTC


README

Scrutinizer Code Quality Code Coverage Build Status License

CCache

About

A small class for chaching information

##Tech

PHP >= 5.4.0
Tested on Anax MVC >= 2.0.4

Introduction

Instantiate an object of CCache:

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

Or instantiate an object of CCache as a shared service within the Anax framework:

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

Methods

  1. __construct ( $dir) - Constructor
  2. get ($key) - Get an item from the cache if its there.
  3. put ($key, $item) - Put an item to the cache.
  4. prune($key) - Prune a item from cache.
  5. pruneAll() - Prune all items from cache.

Calling of Methods

To properly use the methods listed above you can call it as follows (Assuming you've set the service as a shared service in your frontcontroller)

Inside a class that extends/implements/uses \Anax\DI\TInjectionAware:

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

In your frontcontroller:

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

To prune all items from cache:

$app->cache->pruneAll();

Composer

You can add ccache to your composer.json file like this.

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

License

MIT