當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。