/** * Set a value into the cache * * @param \Itkg\Core\CacheableInterface $item * * @return void */ public function set(CacheableInterface $item) { $this->getConnection()->set($item->getHashKey(), $item->getDataForCache()); if (null !== $item->getTtl()) { $this->getConnection()->expire($item->getHashKey(), $item->getTtl()); } }
/** * Set a value into the cache * * @param CacheableInterface $item * * @return void */ public function set(CacheableInterface $item) { $this->connection->set($item->getHashKey(), $item->getDataForCache(), $item->getTtl()); }
/** * Get value from cache * Must return false when cache is expired or invalid * * @param \Itkg\Core\CacheableInterface $item * * @return mixed */ public function get(CacheableInterface $item) { $targetFile = $this->getTargetFile($item->getHashKey()); $return = false; if (file_exists($targetFile)) { if ($item->getTtl() > 0 && filemtime($targetFile) + $item->getTtl() < time()) { $this->remove($item); } else { $return = unserialize(file_get_contents($targetFile, false, null, strlen(self::STR_PREFIX))); } } return $return; }
/** * Set a value into the cache * * @param \Itkg\Core\CacheableInterface $item * * @return void */ public function set(CacheableInterface $item) { $this->provider->save($item->getHashKey(), $item->getDataForCache(), $item->getTtl()); }