graphstory / cache-interface
Generic cache interfaces
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 0
Open Issues: 0
pkg:composer/graphstory/cache-interface
Requires
- php: >=5.4
Requires (Dev)
- desarrolla2/cache: ^2.0
- fabpot/php-cs-fixer: ^1.10
- phpfastcache/phpfastcache: ^3.0
- phpunit/phpunit: 4.8.18
This package is not auto-updated.
Last update: 2025-10-12 00:41:34 UTC
README
Simple cache adapters and interface based on Anthony Ferrara's blog post A Followup To An Open Letter To PHP-FIG.
Installation
Using Composer
Use Composer to install the cache-interface library:
$ composer require graphstory/cache-interface
Usage
// Example using Daniel González's Cache library use Desarrolla2\Cache\Cache; use Desarrolla2\Cache\Adapter\File; use GraphStory\Console\Cache\DesarrollaAdapter; $cacheDir = '/tmp'; $adapter = new File($cacheDir); $adapter->setOption('ttl', 3600); $desarrolla2 = new Cache($adapter); $cache = DesarrollaAdapter($desarrolla2); $cache->set('key', 'myKeyValue', 3600); // later ... echo $cache->get('key');
(The above example was mostly cribbed from the desarrolla2/Cache documentation.)
BYOA (bring your own adapter)
You can write your own adapter by creating a class that implements the CacheAdapter
interface. Use the other adapters as a reference and you should be good to go!