/**
  * 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;
 }
Example #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);
 }
 /**
  * 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;
 }
Example #4
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)
 {
     xcache_set($item->getKey(), $item->getValue(), $ttl);
     return $this;
 }