本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}