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


PHP AbstractAdapter::getOptions方法代码示例

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


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

示例1: setCacheItem

 /**
  * Save item to cache
  * @param string $key
  * @param mixed $value
  * @param array $arr_options - Optional
  * Options: ttl => Overwrite configured ttl with set value. Reverts to configured ttl once completed
  */
 public function setCacheItem($key, $value, $arr_options = array())
 {
     //check if caching is enabled
     $arr_config = $this->getServiceLocator()->get("config");
     if ($arr_config["front_end_application_config"]["cache_enabled"] == FALSE) {
         return FALSE;
     }
     //end if
     //adjust key
     $key = $this->setIdentifier($key);
     try {
         /**
          * Overwrite ttl
          */
         if (is_numeric($arr_options["ttl"])) {
             $old_ttl = $this->storageFactory->getOptions()->getTtl();
             $this->storageFactory->getOptions()->setTtl((int) $arr_options["ttl"]);
             $this->storageFactory->setItem($key, $value);
             //reset ttl
             $this->storageFactory->getOptions()->setTtl($old_ttl);
             return;
         }
         //end if
         $this->storageFactory->setItem($key, $value);
     } catch (\Exception $e) {
         trigger_error($e->getMessage(), E_USER_WARNING);
     }
     //end catch
 }
开发者ID:BanterMediaSA,项目名称:majestic3-open-source,代码行数:36,代码来源:FrontCachesAbstract.php

示例2: testGetOptions

 public function testGetOptions()
 {
     $this->_storage = $this->getMockForAbstractAdapter();
     $options = $this->_storage->getOptions();
     $this->assertInstanceOf('Zend\\Cache\\Storage\\Adapter\\AdapterOptions', $options);
     $this->assertInternalType('boolean', $options->getWritable());
     $this->assertInternalType('boolean', $options->getReadable());
     $this->assertInternalType('integer', $options->getTtl());
     $this->assertInternalType('string', $options->getNamespace());
     $this->assertInternalType('string', $options->getKeyPattern());
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:11,代码来源:AbstractAdapterTest.php

示例3: normalizeKey

 /**
  * normalizes the cache id for zend cache
  *
  * @param string $cacheId The cache id
  *
  * @return string The formated cache id
  */
 protected function normalizeKey($cacheId)
 {
     $cacheId = parent::normalizeKey($cacheId);
     if (($pattern = $this->cache->getOptions()->getKeyPattern()) && !preg_match($pattern, $cacheId)) {
         $pattern = str_replace(array('^[', '*$'), array('[^', ''), $pattern);
         $cacheId = preg_replace($pattern, '_', $cacheId);
     }
     return $cacheId;
 }
开发者ID:gunnilx,项目名称:WurflCache,代码行数:16,代码来源:ZendCacheConnector.php

示例4: onFinish

 /**
  * Cache Response for future requests
  *
  * @param MvcEvent $e
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function onFinish(MvcEvent $e)
 {
     $request = $e->getRequest();
     if (!$request instanceof HttpRequest) {
         return;
     }
     if (!$request->isGet()) {
         return;
     }
     $response = $e->getResponse();
     if ($response instanceof HttpResponse && !$response->isOk()) {
         return;
     }
     // Do not continue if weren't able to compose a key
     if (empty($this->cache_key)) {
         return;
     }
     if (!$this->cacheAdapter->hasItem($this->cache_key)) {
         $resourceIdentifier = $e->getRouteMatch()->getParam('resource');
         $resource = call_user_func($this->getResourceLocatorService(), $resourceIdentifier);
         if (!$resource instanceof Resource || !$resource->isCacheable()) {
             return;
         }
         // Generate Response cache headers based on Resource CacheOptions
         $cacheOptions = $resource->getCacheOptions();
         $cacheControl = new CacheControl();
         $cacheControl->addDirective($cacheOptions->getAccess());
         $cacheControl->addDirective('max-age', $cacheOptions->getMaxAge());
         $cacheControl->addDirective('expires', $cacheOptions->getExpires());
         $cacheControl->addDirective('must-revalidate');
         $dateTime = new \DateTime();
         $dateTime->modify('+ ' . $cacheOptions->getExpires() . 'seconds');
         $expires = new Expires();
         $expires->setDate($dateTime);
         $lastModified = new LastModified();
         $lastModified->setDate(new \DateTime());
         // Add Headers to Response Header
         $response->getHeaders()->addHeader($cacheControl);
         $response->getHeaders()->addHeader($expires);
         $response->getHeaders()->addHeaderLine('Pragma: ' . $cacheOptions->getAccess());
         $response->getHeaders()->addHeader(Etag::fromString('Etag: ' . md5($response->getBody())));
         $response->getHeaders()->addHeader($lastModified);
         // Set cache adapter's TTL using Resource cache expires value
         $this->cacheAdapter->getOptions()->setTtl($cacheOptions->getExpires());
         $this->cacheAdapter->setItem($this->cache_key, $response);
         //return $response;
     }
 }
开发者ID:parrotcage,项目名称:aves,代码行数:54,代码来源:ResponseCacheListenerAggregate.php

示例5: setCacheAdapter

 /**
  * Set Cache Adapter
  *
  * @param \Zend\Cache\Storage\Adapter\AbstractAdapter $cacheAdapter
  */
 public function setCacheAdapter($cacheAdapter)
 {
     $this->cacheAdapter = $cacheAdapter;
     $this->cacheAdapter->getOptions()->setTtl($this->getCacheOptions()->getExpires());
 }
开发者ID:parrotcage,项目名称:aves,代码行数:10,代码来源:Resource.php


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