コード例 #1
0
 /**
  * Persisting our data in the cache, uniquely referenced by a key with an optional expiration TTL time.
  *
  * @param CacheItemInterface          $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();
     static::$store[$key] = $value;
     return $this;
 }
コード例 #2
0
 /**
  * Persisting our data in the cache, uniquely referenced by a key with an optional expiration TTL time.
  *
  * @param CacheItemInterface          $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)
 {
     $this->connect();
     $ttl = $ttl ?: $this->ttl;
     $this->driver->set($item->getKey(), $item->getValue(), $ttl);
     return (bool) ($this->driver->getResultCode() == \Memcached::RES_SUCCESS);
 }
コード例 #3
0
 /**
  * Persisting our data in the cache, uniquely referenced by a key with an optional expiration TTL time.
  *
  * @param CacheItemInterface          $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)
 {
     $this->connect();
     if (!$this->driver->set($item->getKey(), $item->getValue())) {
         return false;
     }
     if ($ttl) {
         $this->driver->expire($item->getKey(), $ttl);
     }
     return $this;
 }
コード例 #4
0
ファイル: XcacheStorage.php プロジェクト: rokite/windwalker
 /**
  * Persisting our data in the cache, uniquely referenced by a key with an optional expiration TTL time.
  *
  * @param CacheItemInterface          $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)
 {
     xcache_set($item->getKey(), $item->getValue(), $ttl);
     return $this;
 }