当前位置: 首页>>代码示例>>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;未经允许,请勿转载。