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


PHP StorageInterface::getMetadata方法代码示例

本文整理汇总了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);
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:10,代码来源:ZendStorageCache.php

示例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;
 }
开发者ID:robocoder,项目名称:solublecomponents,代码行数:54,代码来源:ImageConverter.php

示例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;
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:18,代码来源:KeyListIterator.php

示例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);
 }
开发者ID:robbertkl,项目名称:photolibrary,代码行数:25,代码来源:Library.php

示例5: testGetMetadataReturnsFalseIfNonReadable

 public function testGetMetadataReturnsFalseIfNonReadable()
 {
     $this->_options->setReadable(false);
     $this->assertTrue($this->_storage->setItem('key', 'value'));
     $this->assertFalse($this->_storage->getMetadata('key'));
 }
开发者ID:ninahuanca,项目名称:zf2,代码行数:6,代码来源:CommonAdapterTest.php

示例6: delegatesGetMetadata

 /**
  * @test
  */
 public function delegatesGetMetadata()
 {
     $this->storage->getMetadata('cacheKey')->willReturn(true);
     $return = $this->cache->getMetadata('cacheKey');
     $this->assertTrue($return);
 }
开发者ID:koinephp,项目名称:DelayedCache,代码行数:9,代码来源:DelayedCacheTest.php

示例7: getMetadata

 public function getMetadata($key)
 {
     return $this->storage->getMetadata($key);
 }
开发者ID:nasimnabavi,项目名称:DelayedCache,代码行数:4,代码来源:DelayedCache.php


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