Skip to content

cueBlog-Club/cache

Repository files navigation

CuePhp-Cache

Build Status Code Coverage

Latest Stable Version Total Downloads

Suport Storage Engine

  • InMemory
  • File
  • Memcached
  • Redis
  • Yac

Instanll

compose require cuephp/cache

Cache Usage

use CuePhp\Cache\Engine\InMemoryEngine;
use CuePhp\Cache\Config\InMemoryConfig;

$config = new InMemoryConfig;
$engine = new InMemoryEngine( $config );

$engine->set( 'key', 'value', 10 );

$item = $engine->get('key');
$item->getData(); // return 'value'

Counter Usage

use CuePhp\Cache\Engine\InMemoryEngine;
use CuePhp\Cache\Config\InMemoryConfig;

$config = new InMemoryConfig;
$engine = new InMemoryEngine( $config );

$incrCounter= $engine->incr( 'key' );
$value = $incrCounter->getData(); //return 1 if 'key' not exist

$incrCount = $engine->incr('key', 10);
$value = $incrCounter->getData(); //return 11