cuephp/cache

a light weight cache lib

0.2.0 2021-12-05 14:14 UTC

This package is auto-updated.

Last update: 2024-11-10 00:46:20 UTC


README

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