mrjgreen/cacher

There is no license information available for the latest version (v1.0.1) of this package.

Cache component based on laravel's

This package's canonical repository appears to be gone and the package has been frozen as a result.

Maintainers

Details

github.com/mrjgreen/cacher

v1.0.1 2014-10-19 13:33 UTC

This package is not auto-updated.

Last update: 2024-01-16 00:53:53 UTC


README

Build Status Coverage Status

A simple stackable PHP caching library with Redis, File, Memory (array) and Custom ArrayAccess backends

Installation

Install via composer

{
    "require": {
        "mrjgreen/cacher": "1.*"
    }
}

Usage

$backend = new Cacher\Backends\File('path/to/tmpstorage');

$cache = new Cacher($backend);

$cache->set('key', 'value');

$cache->get('key'); // returns 'value'

Stacking

$fileBackend = new Cacher\Backends\File('path/to/tmpstorage');

// Uses any compatible redis library. EG nrk/predis, irediscent/irediscent
$redisBackend = new Cacher\Backends\Redis(new Predis\Client($config));

$stackedCache = new Cacher($redisBackend, new Cacher($fileBackend));

// Looks in redis then falls back to file before calling the callback function
$stackedCache->get('key', function(){
  return 'value';
});