/** * @param string $key * @return \SplitIO\Component\Cache\Item */ public function getItem($key) { $item = new Item($key); $redisItem = $this->client->get($key); if ($redisItem !== false) { $item->set($redisItem); } return $item; }
/** * Persists a cache item immediately. * * @param \SplitIO\Component\Cache\Item $item * The cache item to save. * * @return bool * True if the item was successfully persisted. False if there was an error. */ public function save(Item $item) { $key = $item->getKey(); $value = $item->get(); //PSR-6 CacheItemInterface doesn't define a method to get the item expiration value. $expiration = method_exists($item, 'getExpiration') ? $item->getExpiration() : 0; if ($this->adapter->save($key, $value, $expiration)) { Di::getLogger()->debug("Saving cache item: {$key} - {$value} - {$expiration}"); return true; } return false; }