Beispiel #1
0
 /**
  * Returns a Cache Item representing the specified key.
  *
  * This method must always return a CacheItemInterface object, even in case of
  * a cache miss. It MUST NOT return null.
  *
  * @param string $key
  *   The key for which to return the corresponding Cache Item.
  *
  * @throws InvalidArgumentException
  *   If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
  *   MUST be thrown.
  *
  * @return CacheItemInterface
  *   The corresponding Cache Item.
  */
 public function getItem($key)
 {
     $item = new CacheItem($this, $key);
     if (isset(self::$cachePool[$this->_pool][$key])) {
         $item->hydrate(self::$cachePool[$this->_pool][$key], true);
     } else {
         $item->hydrate(null, false);
     }
     return $item;
 }
Beispiel #2
0
 /**
  * Returns a Cache Item representing the specified key.
  *
  * This method must always return a CacheItemInterface object, even in case of
  * a cache miss. It MUST NOT return null.
  *
  * @param string $key
  *   The key for which to return the corresponding Cache Item.
  *
  * @throws InvalidArgumentException
  *   If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
  *   MUST be thrown.
  *
  * @return CacheItemInterface
  *   The corresponding Cache Item.
  */
 public function getItem($key)
 {
     $item = new CacheItem($this, $key);
     $value = $this->_connection->get($key);
     if ($value !== false) {
         $item->hydrate($value, true);
     } else {
         $item->hydrate(null, false);
     }
     return $item;
 }
Beispiel #3
0
 /**
  * Create a new cache item
  *
  * @param      $key
  * @param null $value
  * @param null $ttl
  *
  * @return CacheItem
  */
 public function createItem($key, $value = null, $ttl = null)
 {
     $item = new CacheItem($this, $key);
     if ($value !== null) {
         $item->set($value, $ttl);
     }
     return $item;
 }