當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CacheItemInterface::getKey方法代碼示例

本文整理匯總了PHP中Psr\Cache\CacheItemInterface::getKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP CacheItemInterface::getKey方法的具體用法?PHP CacheItemInterface::getKey怎麽用?PHP CacheItemInterface::getKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Cache\CacheItemInterface的用法示例。


在下文中一共展示了CacheItemInterface::getKey方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例3: storeItemInCache

 /**
  * {@inheritdoc}
  */
 protected function storeItemInCache(CacheItemInterface $item, $ttl)
 {
     $key = $this->getHierarchyKey($item->getKey());
     $data = serialize([true, $item->get(), $item->getTags()]);
     if ($ttl === null || $ttl === 0) {
         return $this->cache->set($key, $data);
     }
     return $this->cache->setex($key, $ttl, $data);
 }
開發者ID:php-cache,項目名稱:redis-adapter,代碼行數:12,代碼來源:RedisCachePool.php

示例4: save

 /**
  * {@inheritdoc}
  */
 public function save($key, CacheEntry $data)
 {
     if ($this->lastItem && $this->lastItem->getKey() == $key) {
         $item = $this->lastItem;
     } else {
         $item = $this->cachePool->getItem($key);
     }
     $this->lastItem = null;
     $item->set($data);
     $ttl = $data->getTTL();
     if ($ttl === 0) {
         // No expiration
         $item->expiresAfter(null);
     } else {
         $item->expiresAfter($ttl);
     }
     return $this->cachePool->save($item);
 }
開發者ID:kevinrob,項目名稱:guzzle-cache-middleware,代碼行數:21,代碼來源:Psr6CacheStorage.php

示例5: 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

示例6: 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

示例7: 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

示例8: storeItemInCache

 /**
  * {@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]));
 }
開發者ID:swayok,項目名稱:alternative-laravel-cache,代碼行數:18,代碼來源:HierarchialFilesystemCachePool.php

示例9: 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

示例10: saveDeferred

 /**
  * {@inheritdoc}
  */
 public function saveDeferred(CacheItemInterface $item)
 {
     if (null === $this->values) {
         $this->initialize();
     }
     return !isset($this->values[$item->getKey()]) && $this->fallbackPool->saveDeferred($item);
 }
開發者ID:joelwurtz,項目名稱:symfony,代碼行數:10,代碼來源:PhpArrayAdapter.php

示例11: save

 /**
  * @param CacheItemInterface $item
  * @return bool|void
  */
 public function save(CacheItemInterface $item)
 {
     if (!$item instanceof CacheItem) {
         throw new InvalidArgumentException('The cache item must be an implementation of \\ByJG\\Cache\\Psr\\CacheItem');
     }
     if ($item->getExpiresInSecs() < 1) {
         throw new InvalidArgumentException('Object has expired!');
     }
     $this->_cacheEngine->set($item->getKey(), $item->get(), $item->getExpiresInSecs());
     $this->addElementToBuffer($item);
     return true;
 }
開發者ID:byjg,項目名稱:cache-engine-php,代碼行數:16,代碼來源:CachePool.php

示例12: saveDeferred

 /**
  * {@inheritdoc}
  */
 public function saveDeferred(CacheItemInterface $item)
 {
     if (!$item instanceof CacheItem) {
         return false;
     }
     $this->deferred[$item->getKey()] = $item;
     return true;
 }
開發者ID:alekitto,項目名稱:symfony,代碼行數:11,代碼來源:AbstractAdapter.php

示例13: saveDeferred

 /**
  * {@inheritdoc}
  */
 public function saveDeferred(CacheItemInterface $item)
 {
     if (!$item instanceof Item) {
         throw new InvalidArgumentException('MatthiasMullie\\Scrapbook\\Psr6\\Pool can only save
             MatthiasMullie\\Scrapbook\\Psr6\\Item objects');
     }
     $this->deferred[$item->getKey()] = $item;
     // let's pretend that this actually comes from cache (we'll store it
     // there soon), unless if it's already expired (in which case it will
     // never reach cache...)
     $item->overrideIsHit(!$item->isExpired());
     return true;
 }
開發者ID:matthiasmullie,項目名稱:scrapbook,代碼行數:16,代碼來源:Pool.php

示例14: save

 public function save(CacheItemInterface $item)
 {
     $this->items_[$item->getKey()] = $item;
     return $this;
 }
開發者ID:rindeal,項目名稱:allegro-client,代碼行數:5,代碼來源:Pool.php

示例15: save

 /**
  * 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.
  *
  * @throws InvalidArgumentException
  */
 public function save(CacheItemInterface $item)
 {
     $expirationTime = null;
     if ($item instanceof ExtractableCacheLifetimeInterface) {
         $expirationTime = $item->getCacheLifetime();
     }
     return $this->cacheFrontend->save(serialize($item instanceof ExtractableCacheValueInterface ? $item->getCacheValue() : $item->get()), $this->prepareKey($item->getKey()), $this->tags, $expirationTime);
 }
開發者ID:ecomdev,項目名稱:magento-psr6-bridge,代碼行數:19,代碼來源:CacheItemPool.php


注:本文中的Psr\Cache\CacheItemInterface::getKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。