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


PHP StorageInterface::setOptions方法代碼示例

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


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

示例1: delegatesSetOptions

 /**
  * @test
  */
 public function delegatesSetOptions()
 {
     $options = ['foo'];
     $return = $this->cache->setOptions($options);
     $this->assertSame($this->cache, $return);
     $this->storage->setOptions($options)->shouldHaveBeenCalled();
 }
開發者ID:koinephp,項目名稱:DelayedCache,代碼行數:10,代碼來源:DelayedCacheTest.php

示例2: 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.
  */
 public function save(CacheItemInterface $item)
 {
     if (!$item instanceof CacheItem) {
         throw new InvalidArgumentException('$item must be an instance of ' . CacheItem::class);
     }
     $this->validateKey($item->getKey());
     try {
         $options = false;
         $expiration = $item->getExpiration();
         // @todo I can't see any way to set the TTL on an individual item except by temporarily overwriting the
         //       option on the storage adapter. Not sure if all storage adapters will support this...
         if ($expiration instanceof DateTime) {
             $options = $this->storage->getOptions();
             $new = clone $options;
             $interval = $expiration->diff(new DateTime(), true);
             $new->setTtl($interval->format('%s'));
             $this->storage->setOptions($new);
         }
         $saved = $this->storage->setItem($item->getKey(), $item->get());
         if ($options) {
             $this->storage->setOptions($options);
         }
     } catch (Exception\InvalidArgumentException $e) {
         throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
     } catch (Exception\ExceptionInterface $e) {
         throw new CacheException($e->getMessage(), $e->getCode(), $e);
     }
     return $saved;
 }
開發者ID:Nyholm,項目名稱:zend-cache-psr6,代碼行數:38,代碼來源:CacheItemPoolAdapter.php

示例3: getItem

 /**
  * @param $cacheKey
  * @param Closure $closure
  * @param null $lifetime
  * @return mixed
  */
 public function getItem($cacheKey, Closure $closure, $lifetime = null)
 {
     // we have to check if we enable the caching in config
     if (!$this->isCachingEnable()) {
         return $closure();
     }
     $data = $this->cachingService->getItem($cacheKey);
     if (!$data) {
         $data = $closure();
         if ($lifetime > 0) {
             $this->cachingService->setOptions($this->cachingService->getOptions()->setTtl($lifetime));
         }
         $this->cachingService->setItem($cacheKey, $data);
     }
     return $data;
 }
開發者ID:kokspflanze,項目名稱:PServerCore,代碼行數:22,代碼來源:CachingHelper.php

示例4: testOptionsFluentInterface

 public function testOptionsFluentInterface()
 {
     $options = $this->_storage->getOptions();
     foreach ($options->toArray() as $option => $value) {
         $method = ucwords(str_replace('_', ' ', $option));
         $method = 'set' . str_replace(' ', '', $method);
         $this->assertSame($options, $options->{$method}($value), "Method '{$method}' doesn't implement the fluent interface");
     }
     $this->assertSame($this->_storage, $this->_storage->setOptions($options), "Method 'setOptions' doesn't implement the fluent interface");
 }
開發者ID:ninahuanca,項目名稱:zf2,代碼行數:10,代碼來源:CommonAdapterTest.php

示例5: setOptions

 public function setOptions($options)
 {
     $this->storage->setOptions($options);
     return $this;
 }
開發者ID:nasimnabavi,項目名稱:DelayedCache,代碼行數:5,代碼來源:DelayedCache.php


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