/**
  * Here we pass in a cache key to be fetched from the cache.
  * A CacheItem object will be constructed and returned to us
  *
  * @param string $key The unique key of this item in the cache
  *
  * @return CacheItemInterface  The newly populated CacheItem class representing the stored data in the cache
  */
 public function getItem($key)
 {
     $item = new CacheItem($key);
     if (isset(static::$store[$key])) {
         $item->setValue(static::$store[$key]);
     }
     return $item;
 }
Exemple #2
0
 /**
  * Here we pass in a cache key to be fetched from the cache.
  * A CacheItem object will be constructed and returned to us
  *
  * @param string $key The unique key of this item in the cache
  *
  * @return CacheItemInterface  The newly populated CacheItem class representing the stored data in the cache
  */
 public function getItem($key)
 {
     $item = new CacheItem($key);
     if ($this->exists($key)) {
         $item->setValue(xcache_get($key));
     }
     return $item;
 }
 /**
  * Here we pass in a cache key to be fetched from the cache.
  * A CacheItem object will be constructed and returned to us
  *
  * @param string $key The unique key of this item in the cache
  *
  * @return CacheItemInterface  The newly populated CacheItem class representing the stored data in the cache
  */
 public function getItem($key)
 {
     $item = new CacheItem($key);
     if (isset($this->store[$key])) {
         $item->setValue($this->store[$key]);
     }
     return $item;
 }
 /**
  * Here we pass in a cache key to be fetched from the cache.
  * A CacheItem object will be constructed and returned to us
  *
  * @param string $key The unique key of this item in the cache
  *
  * @return CacheItemInterface  The newly populated CacheItem class representing the stored data in the cache
  */
 public function getItem($key)
 {
     $this->connect();
     $value = $this->driver->get($key);
     $item = new CacheItem($key);
     if ($value !== false) {
         $item->setValue($value);
     }
     return $item;
 }
 /**
  * Here we pass in a cache key to be fetched from the cache.
  * A CacheItem object will be constructed and returned to us
  *
  * @param string $key The unique key of this item in the cache
  *
  * @return CacheItemInterface  The newly populated CacheItem class representing the stored data in the cache
  */
 public function getItem($key)
 {
     $this->connect();
     $value = $this->driver->get($key);
     $code = $this->driver->getResultCode();
     $item = new CacheItem($key);
     if ($code === \Memcached::RES_SUCCESS) {
         $item->setValue($value);
     }
     return $item;
 }
 /**
  * Persisting our data in the cache, uniquely referenced by a key with an optional expiration TTL time.
  *
  * @param CacheItem                   $item The cache item to store.
  * @param int|\DateInterval|\DateTime $ttl  The Time To Live of an item.
  *
  * @return static Return self to support chaining
  */
 public function setItem($item, $ttl = null)
 {
     $key = $item->getKey();
     $value = $item->getValue();
     $fileName = $this->fetchStreamUri($key);
     $filePath = pathinfo($fileName, PATHINFO_DIRNAME);
     if (!is_dir($filePath)) {
         mkdir($filePath, 0770, true);
     }
     if ($this->denyAccess) {
         $value = $this->options['deny_code'] . $value;
     }
     $success = (bool) file_put_contents($fileName, $value, $this->options['file_locking'] ? LOCK_EX : null);
     return $success;
 }