apioo / psx-cache

PSR-6 and PSR-16 implementation using the doctrine cache system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PSX Cache

About

PSR-6 and PSR-16 implementation using the doctrine cache system.

Usage

PSR-6

<?php

$pool = new PSX\Cache\Pool(new Doctrine\Common\Cache\FilesystemCache());
$item = $pool->getItem('foo');

if (!$item->isHit()) {
    $value = doComplexTask();

    $item->set($value);
    $item->expiresAfter(3600);

    $pool->save($item);
} else {
    $value = $item->get();
}

PSR-16

<?php

$cache = new PSX\Cache\SimpleCache(new Doctrine\Common\Cache\FilesystemCache());
$value = $cache->get('foo');

if ($value === null) {
    $value = doComplexTask();

    $cache->set('foo', $value, 3600);
}

About

PSR-6 and PSR-16 implementation using the doctrine cache system

License:Apache License 2.0


Languages

Language:PHP 100.0%