Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.32 KB

File metadata and controls

39 lines (31 loc) · 1.32 KB

InitPHP Cache — Documentation

initphp/cache is a PSR-16 cache library with interchangeable handlers. You configure a handler once through the Cache::create() factory and then use the standard PSR-16 API everywhere.

Contents

  1. Getting started — install, the factory, the read-through pattern.
  2. Configuration & options — every option of every handler.
  3. PSR-16 behaviour & the handler API — keys, TTLs, bulk methods and the counter contract.
  4. Handlers
  5. Exceptions

The 30-second version

use InitPHP\Cache\Cache;
use InitPHP\Cache\Handler\File;

$cache = Cache::create(File::class, ['path' => __DIR__ . '/var/cache']);

$cache->set('key', 'value', 300); // store for 5 minutes
$cache->get('key');               // "value"
$cache->get('missing', 'default');// "default"
$cache->has('key');               // true
$cache->delete('key');            // true

Every handler implements InitPHP\Cache\CacheInterface, which extends Psr\SimpleCache\CacheInterface. Code that depends on the PSR interface works with any handler unchanged.