本文整理汇总了PHP中Zend\Cache\Storage\StorageInterface::getMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageInterface::getMetadata方法的具体用法?PHP StorageInterface::getMetadata怎么用?PHP StorageInterface::getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Cache\Storage\StorageInterface
的用法示例。
在下文中一共展示了StorageInterface::getMetadata方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doGetStats
/**
* {@inheritDoc}
*/
protected function doGetStats()
{
/* @var $storage TotalSpaceCapableInterface */
/* @var $storage AvailableSpaceCapableInterface */
$storage = $this->storage;
return array(Cache::STATS_HITS => $this->storage->getMetadata(Cache::STATS_HITS), Cache::STATS_MISSES => $this->storage->getMetadata(Cache::STATS_MISSES), Cache::STATS_UPTIME => $this->storage->getMetadata(Cache::STATS_UPTIME), Cache::STATS_MEMORY_USAGE => $storage instanceof TotalSpaceCapableInterface ? $storage->getTotalSpace() : null, Cache::STATS_MEMORY_AVAILIABLE => $storage instanceof AvailableSpaceCapableInterface ? $storage->getAvailableSpace() : null);
}
示例2: getThumbnail
/**
*
* @param string $filename
* @param \Soluble\Media\BoxDimension $box
* @param string $format
* @param int $quality
* @throws \Soluble\Media\Converter\Exception
* @throws \Exception
*/
public function getThumbnail($filename, BoxDimension $box, $format = null, $quality = null)
{
$width = $box->getWidth();
$height = $box->getHeight();
if ($quality === null) {
$quality = $this->default_quality;
}
$cache_key = md5("{$filename}/{$width}/{$height}/{$quality}/{$format}");
if ($this->cacheEnabled && $this->cacheStorage->hasItem($cache_key)) {
$cacheMd = $this->cacheStorage->getMetadata($cache_key);
if ($cacheMd['mtime'] < filemtime($filename)) {
// invalid cache
$binaryContent = $this->generateThumbnail($filename, $box, $format, $quality);
$this->cacheStorage->setItem($cache_key, $binaryContent);
} else {
$binaryContent = $this->cacheStorage->getItem($cache_key);
}
} else {
$binaryContent = $this->generateThumbnail($filename, $box, $format, $quality);
$this->cacheStorage->setItem($cache_key, $binaryContent);
}
switch ($format) {
case 'jpg':
$content_type = 'image/jpeg';
break;
case 'png':
$content_type = 'image/png';
break;
case 'gif':
$content_type = 'image/gif';
break;
default:
throw new \Exception("Unsupported format '{$format}'");
}
header("Content-type: {$content_type}", true);
header("Accept-Ranges: bytes", true);
header("Cache-control: max-age=2592000, public", true);
header("Content-Disposition: inline; filename=\"{$filename}\";", true);
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT', true);
header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('+1 years')) . ' GMT', true);
//header('Content-Disposition: attachment; filename="downloaded.pdf"');
header('Pragma: cache', true);
echo $binaryContent;
die;
}
示例3: current
/**
* Get current key, value or metadata.
*
* @return mixed
*/
public function current()
{
if ($this->mode == IteratorInterface::CURRENT_AS_SELF) {
return $this;
}
$key = $this->key();
if ($this->mode == IteratorInterface::CURRENT_AS_METADATA) {
return $this->storage->getMetadata($key);
} elseif ($this->mode == IteratorInterface::CURRENT_AS_VALUE) {
return $this->storage->getItem($key);
}
return $key;
}
示例4: loadFromCache
/**
* Load an entry belonging to the given key from our cache (if any)
*
* @param string $key key to look for in the cache (should match /^[a-z0-9_+-]*$/Di)
* @param int $mtime unix timestamp to compare the cache entry with (the entry will be ignored if older than $mtime)
* @return mixed entry from cache or false if its key isn't found in cache or the entry is too old
*/
protected static function loadFromCache($key, $mtime = 0)
{
try {
self::validateCache();
} catch (\Exception $exception) {
// Fake an exception from getItem, so the cache's own EventManager can determine what to do with it
$result = false;
return self::triggerCacheException('getItem', array('key' => &$key), $result, $exception);
}
if (!self::$cache->hasItem($key)) {
return false;
}
$meta = self::$cache->getMetadata($key);
if (!array_key_exists('mtime', $meta) || $meta['mtime'] < $mtime) {
return false;
}
return self::$cache->getItem($key);
}
示例5: testGetMetadataReturnsFalseIfNonReadable
public function testGetMetadataReturnsFalseIfNonReadable()
{
$this->_options->setReadable(false);
$this->assertTrue($this->_storage->setItem('key', 'value'));
$this->assertFalse($this->_storage->getMetadata('key'));
}
示例6: delegatesGetMetadata
/**
* @test
*/
public function delegatesGetMetadata()
{
$this->storage->getMetadata('cacheKey')->willReturn(true);
$return = $this->cache->getMetadata('cacheKey');
$this->assertTrue($return);
}
示例7: getMetadata
public function getMetadata($key)
{
return $this->storage->getMetadata($key);
}