当前位置: 首页>>代码示例>>PHP>>正文


PHP CacheItemInterface::get方法代码示例

本文整理汇总了PHP中Psr\Cache\CacheItemInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheItemInterface::get方法的具体用法?PHP CacheItemInterface::get怎么用?PHP CacheItemInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Cache\CacheItemInterface的用法示例。


在下文中一共展示了CacheItemInterface::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: storeItemInCache

 protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     if ($ttl < 0) {
         return false;
     }
     return apc_store($key, $item->get(), $ttl);
 }
开发者ID:aequasi,项目名称:cache-1,代码行数:7,代码来源:ApcCachePool.php

示例2: storeItemInCache

 protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     if ($ttl === null) {
         $ttl = 0;
     }
     return $this->cache->save($key, serialize($item->get()), $ttl);
 }
开发者ID:gitter-badger,项目名称:cache-1,代码行数:7,代码来源:DoctrineCachePool.php

示例3: storeItemInCache

 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()]));
 }
开发者ID:gitter-badger,项目名称:cache-1,代码行数:8,代码来源:FilesystemCachePool.php

示例4: storeItemInCache

 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);
 }
开发者ID:gitter-badger,项目名称:cache-1,代码行数:8,代码来源:MemcachedCachePool.php

示例5: storeItemInCache

 /**
  * {@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;
 }
开发者ID:php-cache,项目名称:cache,代码行数:12,代码来源:MongoDBCachePool.php

示例6: storeItemInCache

 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;
 }
开发者ID:fervo,项目名称:mongodb-adapter,代码行数:9,代码来源:MongoDBCachePool.php

示例7: save

 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;
 }
开发者ID:ayoah,项目名称:symfony,代码行数:9,代码来源:PhpArrayAdapterTest.php

示例8: storeItemInCache

 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);
 }
开发者ID:aequasi,项目名称:cache-1,代码行数:9,代码来源:RedisCachePool.php

示例9: save

 /**
  * {@inheritdoc}
  */
 public function save(ItemInterface $item)
 {
     $ttl = $item->getTtlInSecond();
     $this->_tags = $item->getTags();
     $item->setHit(true);
     $success = $this->cache_adapter->save($item->get(), $item->getKey(), $this->_tags, is_null($ttl) ? 0 : $ttl);
     $item->setHit($success);
     return $this;
 }
开发者ID:MacFJA,项目名称:apix-cache,代码行数:12,代码来源:TaggablePool.php

示例10: save

 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;
 }
开发者ID:akankov,项目名称:cache-bundle,代码行数:9,代码来源:LoggingCachePool.php

示例11: storeItemInCache

 /**
  * {@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);
 }
开发者ID:php-cache,项目名称:apcu-adapter,代码行数:13,代码来源:ApcuCachePool.php

示例12: tryToSetTokenFromDecorated

 /**
  * @return bool
  */
 private function tryToSetTokenFromDecorated()
 {
     if (empty($this->token)) {
         try {
             $this->token = Token::fromSealed($this->password, $this->decorated->get());
         } catch (Throwable $t) {
         }
     }
     return isset($this->token);
 }
开发者ID:jeskew,项目名称:psr6-encrypting-decorator,代码行数:13,代码来源:ItemDecorator.php

示例13: storeItemInCache

 /**
  * {@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;
 }
开发者ID:florianv,项目名称:laravel-swap,代码行数:15,代码来源:LaravelStoreCachePool.php

示例14: storeItemInCache

 /**
  * {@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);
 }
开发者ID:php-cache,项目名称:cache,代码行数:17,代码来源:MemcachedCachePool.php

示例15: driverWrite

 /**
  * @param \Psr\Cache\CacheItemInterface $item
  * @return mixed
  * @throws \InvalidArgumentException
  */
 protected function driverWrite(CacheItemInterface $item)
 {
     /**
      * Check for Cross-Driver type confusion
      */
     if ($item instanceof Item) {
         try {
             $result = (array) $this->getCollection()->update(['_id' => $item->getKey()], ['$set' => [self::DRIVER_EDATE_WRAPPER_INDEX => $item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time()), self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY)]], ['upsert' => true, 'multiple' => false]);
         } catch (MongoCursorException $e) {
             return false;
         }
         return isset($result['ok']) ? $result['ok'] == 1 : true;
     } else {
         throw new \InvalidArgumentException('Cross-Driver type confusion detected');
     }
 }
开发者ID:jigoshop,项目名称:Jigoshop2,代码行数:21,代码来源:Driver.php


注:本文中的Psr\Cache\CacheItemInterface::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。