/** * 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; }
/** * 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)); } }