php Psr-Cache-CacheItemInterface类(方法)实例源码

下面列出了php Psr-Cache-CacheItemInterface 类(方法)源码代码实例,从而了解它的用法。

作者:aequas    项目:cache-   
protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     if ($ttl < 0) {
         return false;
     }
     return apc_store($key, $item->get(), $ttl);
 }

作者:jeske    项目:psr6-encrypting-decorato   
private function finalizeItem(CacheItemInterface $item)
 {
     if ($item instanceof ItemDecorator) {
         return $item->finalize();
     }
     throw new InvalidArgumentException('The provided cache item cannot' . ' be saved, as it did not originate from this cache.');
 }

作者:gitter-badge    项目:cache-   
protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     if ($ttl === null) {
         $ttl = 0;
     }
     return $this->cache->save($key, serialize($item->get()), $ttl);
 }

作者:jeske    项目:psr6-encrypting-decorato   
private function proxySave(CacheItemInterface $item, $deferred = false)
 {
     if ($item instanceof ItemDecorator) {
         return $this->decorated->{$deferred ? 'saveDeferred' : 'save'}($item->getDecorated());
     }
     throw new InvalidArgumentException('The provided cache item cannot' . ' be saved, as it did not originate from this cache.');
 }

作者:gitter-badge    项目:cache-   
protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     $file = $this->getFilePath($key);
     if ($this->filesystem->has($file)) {
         $this->filesystem->delete($file);
     }
     return $this->filesystem->write($file, serialize([$ttl === null ? null : time() + $ttl, $item->get()]));
 }

作者:gitter-badge    项目:cache-   
protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     if ($ttl === null) {
         $ttl = 0;
     }
     $key = $this->getHierarchyKey($key);
     return $this->cache->set($key, serialize([true, $item->get()]), $ttl);
 }

作者:ferv    项目:mongodb-adapte   
protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     $object = ['_id' => $key, 'data' => serialize($item->get())];
     if ($ttl) {
         $object['expiresAt'] = new UTCDateTime((time() + $ttl) * 1000);
     }
     $this->collection->updateOne(['_id' => $key], ['$set' => $object], ['upsert' => true]);
     return true;
 }

作者:php-cach    项目:cach   
/**
  * {@inheritdoc}
  */
 protected function storeItemInCache(CacheItemInterface $item, $ttl)
 {
     $object = ['_id' => $item->getKey(), 'data' => serialize($item->get())];
     if ($ttl) {
         $object['expiresAt'] = time() + $ttl;
     }
     $this->collection->updateOne(['_id' => $item->getKey()], ['$set' => $object], ['upsert' => true]);
     return true;
 }

作者:ayoa    项目:symfon   
public function save(CacheItemInterface $item)
 {
     call_user_func(\Closure::bind(function () use($item) {
         $this->values[$item->getKey()] = $item->get();
         $this->warmUp($this->values);
         $this->values = eval(substr(file_get_contents($this->file), 6));
     }, $this, PhpArrayAdapter::class));
     return true;
 }

作者:aequas    项目:cache-   
protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     $key = $this->getHierarchyKey($key);
     $data = serialize([true, $item->get()]);
     if ($ttl === null) {
         return $this->cache->set($key, $data);
     }
     return $this->cache->setex($key, $ttl, $data);
 }

作者:akanko    项目:cache-bundl   
public function save(CacheItemInterface $item)
 {
     $itemClone = clone $item;
     $itemClone->set(sprintf('<DATA:%s', gettype($item->get())));
     $call = $this->timeCall(__FUNCTION__, [$item]);
     $call->arguments = ['<CacheItem>', $itemClone];
     $this->calls[] = $call;
     return $call->result;
 }

作者:php-cach    项目:apcu-adapte   
/**
  * {@inheritdoc}
  */
 protected function storeItemInCache(CacheItemInterface $item, $ttl)
 {
     if ($this->skipIfCli()) {
         return false;
     }
     if ($ttl < 0) {
         return false;
     }
     return apcu_store($item->getKey(), $item->get(), $ttl);
 }

作者:swayo    项目:alternative-laravel-cach   
/**
  * {@inheritdoc}
  * @throws \InvalidArgumentException
  * @throws \League\Flysystem\FileNotFoundException
  * @throws \League\Flysystem\FileExistsException
  */
 protected function storeItemInCache(CacheItemInterface $item, $ttl)
 {
     $file = $this->getFilePath($item->getKey());
     if ($this->filesystem->has($file)) {
         $this->filesystem->delete($file);
     }
     $tags = [];
     if ($item instanceof TaggableItemInterface) {
         $tags = $item->getTags();
     }
     return $this->filesystem->write($file, serialize([$ttl === null ? null : time() + $ttl, $item->get(), $tags]));
 }

作者:florian    项目:laravel-swa   
/**
  * {@inheritdoc}
  */
 protected function storeItemInCache(CacheItemInterface $item, $ttl)
 {
     if ($ttl < 0) {
         return false;
     }
     $ttl = null === $ttl ? 0 : $ttl / 60;
     if (null === ($value = $item->get())) {
         $value = self::NULL_VALUE;
     }
     $this->store->put($item->getKey(), $value, $ttl);
     return true;
 }

作者:php-cach    项目:cach   
/**
  * {@inheritdoc}
  */
 protected function storeItemInCache(CacheItemInterface $item, $ttl)
 {
     if ($ttl === null) {
         $ttl = 0;
     } elseif ($ttl < 0) {
         return false;
     } elseif ($ttl > 86400 * 30) {
         // Any time higher than 30 days is interpreted as a unix timestamp date.
         // https://github.com/memcached/memcached/wiki/Programming#expiration
         $ttl = time() + $ttl;
     }
     $key = $this->getHierarchyKey($item->getKey());
     return $this->cache->set($key, serialize([true, $item->get(), []]), $ttl);
 }

作者:jigosho    项目:Jigoshop   
/**
  * @param \Psr\Cache\CacheItemInterface $item
  * @return bool
  * @throws \InvalidArgumentException
  */
 protected function driverDelete(CacheItemInterface $item)
 {
     /**
      * Check for Cross-Driver type confusion
      */
     if ($item instanceof Item) {
         return xcache_unset($item->getKey());
     } else {
         throw new \InvalidArgumentException('Cross-Driver type confusion detected');
     }
 }

作者:php-cach    项目:doctrine-adapte   
/**
  * {@inheritdoc}
  */
 protected function storeItemInCache(CacheItemInterface $item, $ttl)
 {
     if ($ttl === null) {
         $ttl = 0;
     }
     $tags = [];
     if ($item instanceof TaggableItemInterface) {
         $tags = $item->getTags();
     }
     $data = serialize([true, $item->get(), $tags]);
     return $this->cache->save($item->getKey(), $data, $ttl);
 }

作者:php-cach    项目:cach   
/**
  * {@inheritdoc}
  */
 protected function storeItemInCache(CacheItemInterface $item, $ttl)
 {
     if ($ttl < 0) {
         return false;
     }
     $key = $this->getHierarchyKey($item->getKey());
     $data = serialize([true, $item->get(), $item->getTags()]);
     if ($ttl === null || $ttl === 0) {
         return 'OK' === $this->cache->set($key, $data)->getPayload();
     }
     return 'OK' === $this->cache->setex($key, $ttl, $data)->getPayload();
 }

作者:pwnrai    项目:bne   
/**
  * @param ResponseInterface  $response
  * @param CacheItemInterface $item
  * @param array|null         $data
  *
  * @throws \RuntimeException
  *
  * @return array
  */
 protected function handleSuccessfulResponse(ResponseInterface $response, CacheItemInterface $item = null)
 {
     switch ((int) $response->getStatusCode()) {
         case 200:
             $data = json_decode($response->getBody(), true);
             if ($item !== null && $response->hasHeader('Last-Modified') === true) {
                 $item->set(['modified' => $response->getHeader('Last-Modified'), 'json' => $data]);
                 $this->cache->save($item);
             }
             return $data;
         case 304:
             return $item->get()['json'];
         default:
             throw new \RuntimeException('No support added for HTTP Status Code ' . $response->getStatusCode());
     }
 }

作者:subins200    项目:lobby-site-compresso   
/**
  * Minify the data & write it to a CacheItemInterface object.
  *
  * @param  CacheItemInterface $item Cache item to write the data to.
  * @return CacheItemInterface       Cache item with the minifier data.
  */
 public function cache(CacheItemInterface $item)
 {
     $content = $this->execute();
     $item->set($content);
     return $item;
 }


问题


面经


文章

微信
公众号

扫码关注公众号