// boilerplate code example with Memcached, but any // MatthiasMullie\Scrapbook\KeyValueStore adapter will work $client = new \Memcached(); $client->addServer('localhost', 11211); $cache = new \MatthiasMullie\Scrapbook\Adapters\Memcached($client); // create Simplecache object from cache engine $simplecache = new \MatthiasMullie\Scrapbook\Psr16\SimpleCache($cache); // get value from cache $value = $simplecache->get('key'); // ... or store a new value to cache $simplecache->set('key', 'updated-value');
psr/simplecache is an attempt to standardize how cache is implemented across frameworks & libraries in the PHP landscape.
It’s a relatively simple & straightforward driver model interface. It’s very similar to KeyValueStore, but supports fewer features (e.g. CAS is missing).
This project bridges the gap between KeyValueStore based adapters & extras, and PSR-16: any of the Scrapbook tools are accessible in a PSR-16 compatible manner.
Fetch a value from the cache.
Persist data in the cache, uniquely referenced by a key with an optional expiration TTL time.
Delete an item from the cache by its unique key.
Wipe clean the entire cache's keys.
Obtain multiple cache items by their unique keys.
Persisting a set of key => value pairs in the cache, with an optional TTL.
Delete multiple cache items in a single operation.
Identify if an item is in the cache.
Increment a value atomically in the cache by its step value, which defaults to 1.
Decrement a value atomically in the cache by its step value, which defaults to 1.
psr/simplecache is a PHP-FIG (Framework Interop Group) standard for a driver model cache implementation. It's a relatively simple & straightforward driver model interface, very similar to KeyValueStore.
composer require matthiasmullie/scrapbook