Exemplo n.º 1
0
 /**
  * Persists a cache item immediately.
  *
  * @param CacheItemInterface $item
  *   The cache item to save.
  *
  * @return bool
  *   True if the item was successfully persisted. False if there was an error.
  */
 public function save(CacheItemInterface $item)
 {
     if (!$item->isHit()) {
         return false;
     }
     return $this->local->save($item) && $this->remote->save($item);
 }
Exemplo n.º 2
0
 /**
  * Persists a cache item immediately.
  *
  * @param CacheItemInterface $item
  *   The cache item to save.
  *
  * @return bool
  *   True if the item was successfully persisted. False if there was an error.
  */
 public function save(CacheItemInterface $item)
 {
     if (!$item->isHit()) {
         return false;
     }
     $bytes = file_put_contents($this->filenameFor($item->getKey()), serialize($item));
     return false !== $bytes;
 }
Exemplo n.º 3
0
 /**
  * Persists a cache item immediately.
  *
  * @param CacheItemInterface $item
  *   The cache item to save.
  *
  * @return bool
  *   True if the item was successfully persisted. False if there was an error.
  */
 public function save(CacheItemInterface $item)
 {
     if (!$item->isHit()) {
         return false;
     }
     $this->stack[$item->getKey()] = $item;
     return true;
 }
Exemplo n.º 4
0
 /**
  * Persists a cache item immediately.
  *
  * @param CacheItemInterface $item
  *   The cache item to save.
  *
  * @return bool
  *   True if the item was successfully persisted. False if there was an error.
  */
 public function save(CacheItemInterface $item)
 {
     if (!$item->isHit()) {
         return false;
     }
     if ($this->legacy) {
         $store = apc_store($item->getKey(), serialize($item));
     } else {
         $store = apcu_store($item->getKey(), serialize($item));
     }
     return $store;
 }
 public function isHit()
 {
     return $this->decorated->isHit() && $this->isDecryptable();
 }
Exemplo n.º 6
0
 /**
  * Persists a cache item immediately.
  *
  * @param CacheItemInterface $item
  *   The cache item to save.
  *
  * @return bool
  *   True if the item was successfully persisted. False if there was an error.
  */
 public function save(CacheItemInterface $item)
 {
     if (!$item->isHit()) {
         return false;
     }
     return $this->cacheClient->add($item->getKey(), serialize($item));
 }
 /**
  * {@inheritdoc}
  */
 public function save(CacheItemInterface $item)
 {
     // This item has no data
     if (!$item->isHit()) {
         return false;
     }
     if ($item instanceof TaggableItemInterface) {
         $key = $item->getTaggedKey();
     } else {
         $key = $item->getKey();
     }
     $timeToLive = null;
     if ($item instanceof HasExpirationDateInterface) {
         if (null !== ($expirationDate = $item->getExpirationDate())) {
             $timeToLive = $expirationDate->getTimestamp() - time();
         }
     }
     return $this->storeItemInCache($key, $item, $timeToLive);
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function isHit()
 {
     return $this->item->isHit();
 }