Example #1
0
 /**
  * @see \Psr\Cache\CacheItemPoolInterface::save()
  */
 public function save(CacheItemInterface $item)
 {
     // validate key
     $this->validateKey($item->getKey());
     // check whether we have a BasicCacheItem (required to get expiration time)
     if (!$item instanceof BasicCacheItem) {
         throw new InvalidArgumentException('Can only save ' . BasicCacheItem::class . ' as access to expiration time is required');
     }
     // add item to storage and return whether operation was successful
     return $this->getStorage()->set(new BasicStorageItem($item->getKey(), $item->get(), null, $item->getExpirationTime()));
 }