/** * Stores object in pool under its id, also in external cache. * * @param \iveeCore\ICacheable $obj to be stored * * @return void */ public function setItem(ICacheable $obj) { $this->keyToObj[$obj->getKey()] = $obj; if ($this->cache instanceof ICache) { $this->cache->setItem($obj); } }
/** * Stores item in Redis. * * @param \iveeCore\ICacheable $item to be stored * * @return boolean true on success */ public function setItem(ICacheable $item) { $ttl = $item->getCacheExpiry() - time(); if ($ttl < 1) { return false; } return $this->redis->setex($item->getKey(), $ttl, gzencode(serialize($item))); }
/** * Stores item in Memcached. * * @param \iveeCore\ICacheable $item to be stored * * @return boolean true on success */ public function setItem(ICacheable $item) { $ttl = $item->getCacheExpiry() - time(); if ($ttl < 1) { return false; } return $this->memcached->set($item->getKey(), $item, $ttl); }
/** * Stores item in Redis. * * @param \iveeCrest\ICacheable $item to be stored * * @return boolean true on success */ public function setItem(ICacheable $item) { $key = md5($this->uniqId . '_' . $item->getKey()); $ttl = $item->getCacheTTL(); //emulate memcached behaviour: TTLs over 30 days are interpreted as (absolute) UNIX timestamps if ($ttl > 2592000) { $this->redis->set($key, serialize($item)); return $this->redis->expireAt($key, $ttl); } else { return $this->redis->setex($key, $ttl, serialize($item)); } }
/** * Stores item in Memcached. * * @param ICacheable $item to be stored * * @return boolean true on success */ public function setItem(ICacheable $item) { $key = $item->getKey(); //$ckey = md5($this->uniqId . '_' . $key); $ckey = $key; $ttl1 = $item->getCacheTTL(); // ivee TTL $ttl2 = time() + $item->getCacheTTL() - 10; //echo "cache.setItem() TTL=$ttl1 $key\n"; //print_r($item); //if (strpos($key, "oauth/token") !== false) { $ttl2 = time() + 30; } $citem = array('key' => $key, 'value' => $item, 'expire' => $ttl2); $this->cache2[$ckey] = $citem; return 1; }
/** * Returns the date in unix time our copy of this component/action cache. * * @static * @access public * @param ICacheable $obj the ICacheable object * @return int a time in unix format if we have a copy, false otherwise */ public static function isCached(ICacheable &$obj) { return false; if (!$obj->isCacheable()) { return false; } $path = Cacher::getCacheDirectory($obj); if (!$path) { return false; } $file = "{$path}/cache"; return file_exists($file) ? filemtime($file) : false; }