3 namespace pq\Gateway\Table
;
5 class StaticCache
implements CacheInterface
7 protected static $cache = array();
15 function get($key, &$exists = null) {
16 if (($exists = array_key_exists($key, static::$cache))) {
17 list($ttl, $data) = static::$cache[$key];
18 if ($ttl && $ttl < time()) {
19 unset(static::$cache[$key]);
32 * @return \pq\Gateway\Table\StaticCache
34 function set($key, $val, $ttl = 0) {
35 static::$cache[$key] = array(
36 $ttl ?
$ttl +
time() : 0,
45 * @return \pq\Gateway\Table\StaticCache
48 unset(static::$cache[$key]);
55 * @return \pq\Gateway\Table\StaticCache
58 /* no possible concurrency */
65 * @return \pq\Gateway\Table\StaticCache
67 function unlock($key) {
68 /* no possible concurrency */