コード例 #1
0
ファイル: EphemeralCachePool.php プロジェクト: packaged/cache
 /**
  * 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;
 }
コード例 #2
0
ファイル: MemcachePool.php プロジェクト: packaged/cache
 /**
  * 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;
 }