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


PHP AbstractAdapter::addItem方法代码示例

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


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

示例1: getSizes

 /**
  * Returns sizes array for photo identified by Flickr photo id
  *
  * @param  int   $photoId
  * @return array Array of photo size information
  */
 public function getSizes($photoId)
 {
     $sizes = $this->adapter->getItem($photoId);
     if (is_null($sizes)) {
         $sizes = $this->flickr->getSizes($photoId);
         $this->adapter->addItem($photoId, $sizes);
     }
     return $sizes;
 }
开发者ID:neophyt3,项目名称:flaming-archer,代码行数:15,代码来源:FlickrServiceCache.php

示例2: dispatch

 /**
  * @param string $request Request uri
  * @throws \RuntimeException
  * @return \Zend\Http\PhpEnvironment\Response
  */
 public function dispatch($request)
 {
     if (!$this->getResolver()) {
         throw new \RuntimeException("No resolver setted");
     }
     $asset = $this->resolver->resolve($request);
     $content = null;
     $responseCode = 404;
     $headers = Headers::fromString("Content-Type: text/plain");
     if ($asset) {
         $headers = $this->getHeaders($asset->getFile(), $asset->getMime());
         if ($this->browserCached($asset->getFile())) {
             $responseCode = 304;
             $headers->addHeader(Connection::fromString("Connection: close"));
         } else {
             $responseCode = 200;
             $cacheKey = "assets-cache-" . md5($request);
             if ($this->cache) {
                 $content = $this->cache->getItem($cacheKey);
             }
             if (!$content) {
                 $content = $asset->getContent();
                 $assetName = end(explode('\\', get_class($asset)));
                 if (array_key_exists($assetName, $this->filters)) {
                     foreach ($this->filters[$assetName] as $filter) {
                         $content = $filter->filter($content);
                     }
                 }
                 if ($this->cache) {
                     $this->cache->addItem($cacheKey, $content);
                 }
             }
         }
     } else {
         $content = "Asset not found!";
     }
     $response = new Response();
     $response->setStatusCode($responseCode);
     $response->setContent($content);
     $response->setHeaders($headers);
     return $response;
 }
开发者ID:robertdamoc,项目名称:zf2-module-assets,代码行数:47,代码来源:AssetsManager.php

示例3: addItem

 /**
  * Add an item.
  *
  * @param  string $key
  * @param  mixed  $value
  * @return bool
  * @throws Exception\ExceptionInterface
  *
  * @triggers addItem.pre(PreEvent)
  * @triggers addItem.post(PostEvent)
  * @triggers addItem.exception(ExceptionEvent)
  */
 public function addItem($key, $value)
 {
     $options = $this->getOptions();
     if ($options->getWritable() && $options->getClearStatCache()) {
         clearstatcache();
     }
     return parent::addItem($key, $value);
 }
开发者ID:tillk,项目名称:vufind,代码行数:20,代码来源:Filesystem.php

示例4: addItem

 /**
  * Add an item.
  *
  * Options:
  *  - namespace <string> optional
  *    - The namespace to use (Default: namespace of object)
  *  - tags <array> optional
  *    - An array of tags
  *
  * @param  string $key
  * @param  mixed  $value
  * @param  array  $options
  * @return boolean
  * @throws Exception\ExceptionInterface
  *
  * @triggers addItem.pre(PreEvent)
  * @triggers addItem.post(PostEvent)
  * @triggers addItem.exception(ExceptionEvent)
  */
 public function addItem($key, $value, array $options = array())
 {
     $baseOptions = $this->getOptions();
     if ($baseOptions->getWritable() && $baseOptions->getClearStatCache()) {
         clearstatcache();
     }
     return parent::addItem($key, $value, $options);
 }
开发者ID:brikou,项目名称:zend_cache,代码行数:27,代码来源:Filesystem.php


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