joegreen0991 / cacher
Cache component based on laravel's
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Installs: 6 406
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 4
Forks: 1
pkg:composer/joegreen0991/cacher
Requires
- php: >=5.4.0
Requires (Dev)
- codeception/specify: *
- mockery/mockery: dev-master@dev
- predis/predis: *
- satooshi/php-coveralls: dev-master
Suggests
This package is not auto-updated.
Last update: 2024-01-20 12:00:45 UTC
README
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'; });