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


PHP Storage\StorageInterface类代码示例

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


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

示例1: it_should_save_parsed_annotations_in_cache

 /**
  * @param \Zend\Cache\Storage\StorageInterface $cache
  */
 public function it_should_save_parsed_annotations_in_cache($cache)
 {
     // TODO: fix me!
     // $cache->hasItem will return ProphecyObject which will always return true in the if.
     // Therefore the conditions will be incorrect.
     return;
     $cache->hasItem('cache-key')->willReturn(false);
     $this->mockConfiguration($cache);
     $this->getFormSpecification('stdClass');
     $cache->setItem('cache-key', Argument::type('ArrayObject'))->shouldHaveBeenCalled();
 }
开发者ID:phpro,项目名称:zf-annotated-forms,代码行数:14,代码来源:BuilderSpec.php

示例2: remove

 /**
  * @param mixed $key
  * @return bool
  */
 public function remove($key)
 {
     if (!$this->isKey($key)) {
         $key = $this->createKey($key);
     }
     return $this->cache->removeItem($key);
 }
开发者ID:lazhacks,项目名称:h2-zex-common,代码行数:11,代码来源:RedisCache.php

示例3: provide

 public function provide($container)
 {
     $instance = $this->instanceManager->getInstanceFromRequest();
     $pages = [];
     try {
         $container = $this->navigationManager->findContainerByNameAndInstance($container, $instance);
     } catch (ContainerNotFoundException $e) {
         return [];
     }
     $key = hash('sha256', serialize($container));
     if ($this->storage->hasItem($key)) {
         return $this->storage->getItem($key);
     }
     foreach ($container->getPages() as $page) {
         $addPage = $this->buildPage($page);
         $hasUri = isset($addPage['uri']);
         $hasMvc = isset($addPage['action']) || isset($addPage['controller']) || isset($addPage['route']);
         $hasProvider = isset($addPage['provider']);
         if ($hasUri || $hasMvc || $hasProvider) {
             $pages[] = $addPage;
         }
     }
     $this->storage->setItem($key, $pages);
     return $pages;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:25,代码来源:ContainerRepositoryProvider.php

示例4: setValue

 /**
  * Sets or removes value from cache
  *
  * @param string $name
  * @param string $value
  * @return void
  */
 public function setValue($name, $value = null)
 {
     if ($value === null) {
         $this->container->removeItem($name);
     } else {
         $this->container->setItem($name, $value);
     }
 }
开发者ID:ArchangelDesign,项目名称:stampmaster,代码行数:15,代码来源:CacheStorage.php

示例5: warm

 /**
  * @param  null|array $arguments Must be serializable.
  * @return void
  */
 public function warm($arguments = null)
 {
     $callable = $this->callable;
     if (is_array($arguments)) {
         $value = call_user_func_array($callable, $arguments);
     } else {
         $value = $callable();
     }
     $cacheKey = Cache::makeCacheKey($this->name, $arguments);
     $this->storage->addItem($cacheKey, serialize($value));
 }
开发者ID:drcts,项目名称:closure-cache,代码行数:15,代码来源:Operation.php

示例6: setItems

 /**
  * Set array of items
  * If items already exists, they are replaced
  * 
  * @access public
  * @param array $items
  */
 public function setItems($items)
 {
     $existingItemsKeys = array_flip($this->cacheAdapter->hasItems(array_keys($items)));
     $existingItems = array_intersect_key($items, $existingItemsKeys);
     $nonExistingItems = array_diff_key($items, $existingItemsKeys);
     if (count($existingItems) > 0) {
         $this->cacheAdapter->replaceItems($existingItems);
     }
     if (count($nonExistingItems) > 0) {
         $this->cacheAdapter->setItems($nonExistingItems);
     }
 }
开发者ID:camelcasetechsd,项目名称:certigate,代码行数:19,代码来源:Cache.php

示例7: invalidate

 /**
  * @param Event  $e
  * @param string $class
  * @param string $event
  * @return void
  */
 public function invalidate(Event $e, $class, $event)
 {
     $term = $e->getParam('term');
     $result = false;
     if ($term instanceof TaxonomyTermInterface) {
         $result = $this->cacheService->clearByTags(['route_taxonomy/term/get', 'param_term_' . $term->getId()]);
         $this->cacheService->clearByTags(['navigation/render']);
         $this->clearParents($term);
     }
     if ($this->storage instanceof FlushableInterface && !$result) {
         $this->storage->flush();
     }
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:19,代码来源:TaxonomyStorageInvalidator.php

示例8: getResult

 protected function getResult()
 {
     if ($this->cache->hasItem('result')) {
         return $this->cache->getItem('result');
     }
     // The bellow code do not work with zend
     // $this->cache->setItem('result', $this->calculation);
     // $result = $this->cache->getItem('result');
     $calculation = $this->calculation;
     $result = $calculation();
     $this->cache->setItem('result', $result);
     return $result;
 }
开发者ID:koinephp,项目名称:DelayedCache,代码行数:13,代码来源:RegularCache.php

示例9: invalidate

 /**
  * @param Event  $e
  * @param string $class
  * @param string $event
  * @return void
  */
 public function invalidate(Event $e, $class, $event)
 {
     $repository = $e->getParam('repository');
     $result = false;
     if ($repository instanceof EntityInterface) {
         $result = $this->cacheService->clearByTags(['route_entity/page', 'param_entity_' . $repository->getId()]);
         $this->clearTaxonomyTerms($repository->getTaxonomyTerms());
     } elseif ($repository instanceof PageRepositoryInterface) {
         $result = $this->cacheService->clearByTags(['route_page/view', 'param_page_' . $repository->getId()]);
     }
     if ($this->storage instanceof FlushableInterface && !$result) {
         $this->storage->flush();
     }
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:20,代码来源:RepositoryStorageInvalidator.php

示例10: render

 public function render($limit = 25)
 {
     $user = $this->userManager->getUserFromAuthenticator();
     $key = hash('sha256', serialize($user));
     $output = '';
     if ($this->storage->hasItem($key)) {
         //return $this->storage->getItem($key);
     }
     if ($user) {
         $notifications = $this->notificationManager->findNotificationsBySubscriber($user, $limit);
         $output = $this->renderer->render($this->template, ['notifications' => $notifications]);
         $this->storage->setItem($key, $output);
     }
     return $output;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:15,代码来源:Notification.php

示例11: getUnrevisedRevisions

 public function getUnrevisedRevisions(TaxonomyTermInterface $term)
 {
     $key = hash('sha256', serialize($term));
     if ($this->storage->hasItem($key)) {
         return $this->storage->getItem($key);
     }
     $entities = $this->getEntities($term);
     $collection = new ArrayCollection();
     $this->iterEntities($entities, $collection, 'isRevised');
     $iterator = $collection->getIterator();
     $iterator->ksort();
     $collection = new ArrayCollection(iterator_to_array($iterator));
     $this->storage->setItem($key, $collection);
     return $collection;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:15,代码来源:SubjectManager.php

示例12: testTagable

 public function testTagable()
 {
     if (!$this->_storage instanceof TaggableInterface) {
         $this->markTestSkipped("Storage doesn't implement TaggableInterface");
     }
     $this->assertSame(array(), $this->_storage->setItems(array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3')));
     $this->assertTrue($this->_storage->setTags('key1', array('tag1a', 'tag1b')));
     $this->assertTrue($this->_storage->setTags('key2', array('tag2a', 'tag2b')));
     $this->assertTrue($this->_storage->setTags('key3', array('tag3a', 'tag3b')));
     $this->assertFalse($this->_storage->setTags('missing', array('tag')));
     // return tags
     $tags = $this->_storage->getTags('key1');
     $this->assertInternalType('array', $tags);
     sort($tags);
     $this->assertSame(array('tag1a', 'tag1b'), $tags);
     // this should remove nothing
     $this->assertTrue($this->_storage->clearByTags(array('tag1a', 'tag2a')));
     $this->assertTrue($this->_storage->hasItem('key1'));
     $this->assertTrue($this->_storage->hasItem('key2'));
     $this->assertTrue($this->_storage->hasItem('key3'));
     // this should remove key1 and key2
     $this->assertTrue($this->_storage->clearByTags(array('tag1a', 'tag2b'), true));
     $this->assertFalse($this->_storage->hasItem('key1'));
     $this->assertFalse($this->_storage->hasItem('key2'));
     $this->assertTrue($this->_storage->hasItem('key3'));
     // this should remove key3
     $this->assertTrue($this->_storage->clearByTags(array('tag3a', 'tag3b'), true));
     $this->assertFalse($this->_storage->hasItem('key1'));
     $this->assertFalse($this->_storage->hasItem('key2'));
     $this->assertFalse($this->_storage->hasItem('key3'));
 }
开发者ID:ninahuanca,项目名称:zf2,代码行数:31,代码来源:CommonAdapterTest.php

示例13: save

 /**
  * Persists a cache item immediately.
  *
  * @param CacheItemInterface $item
  *   The cache item to save.
  *
  * @return bool
  *   True if the item was successfully persisted. False if there was an error.
  */
 public function save(CacheItemInterface $item)
 {
     if (!$item instanceof CacheItem) {
         throw new InvalidArgumentException('$item must be an instance of ' . CacheItem::class);
     }
     $this->validateKey($item->getKey());
     try {
         $options = false;
         $expiration = $item->getExpiration();
         // @todo I can't see any way to set the TTL on an individual item except by temporarily overwriting the
         //       option on the storage adapter. Not sure if all storage adapters will support this...
         if ($expiration instanceof DateTime) {
             $options = $this->storage->getOptions();
             $new = clone $options;
             $interval = $expiration->diff(new DateTime(), true);
             $new->setTtl($interval->format('%s'));
             $this->storage->setOptions($new);
         }
         $saved = $this->storage->setItem($item->getKey(), $item->get());
         if ($options) {
             $this->storage->setOptions($options);
         }
     } catch (Exception\InvalidArgumentException $e) {
         throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
     } catch (Exception\ExceptionInterface $e) {
         throw new CacheException($e->getMessage(), $e->getCode(), $e);
     }
     return $saved;
 }
开发者ID:Nyholm,项目名称:zend-cache-psr6,代码行数:38,代码来源:CacheItemPoolAdapter.php

示例14: getPluginByInstanceId

 /**
  * Get a plugin by instance Id
  *
  * @param integer $pluginInstanceId Plugin Instance Id
  *
  * @return array|mixed
  * @throws \Rcm\Exception\PluginInstanceNotFoundException
  * @deprecated
  */
 public function getPluginByInstanceId($pluginInstanceId)
 {
     $cacheId = 'rcmPluginInstance_' . $pluginInstanceId;
     if ($this->cache->hasItem($cacheId)) {
         $return = $this->cache->getItem($cacheId);
         $return['fromCache'] = true;
         return $return;
     }
     $pluginInstance = $this->getInstanceEntity($pluginInstanceId);
     if (empty($pluginInstance)) {
         throw new PluginInstanceNotFoundException('Plugin for instance id ' . $pluginInstanceId . ' not found.');
     }
     $instanceConfig = $this->getInstanceConfigFromEntity($pluginInstance);
     $return = $this->getPluginViewData($pluginInstance->getPlugin(), $pluginInstanceId, $instanceConfig);
     if ($pluginInstance->isSiteWide()) {
         $return['siteWide'] = true;
         $displayName = $pluginInstance->getDisplayName();
         if (!empty($displayName)) {
             $return['displayName'] = $displayName;
         }
     }
     $return['md5'] = $pluginInstance->getMd5();
     if ($return['canCache']) {
         $this->cache->setItem($cacheId, $return);
     }
     return $return;
 }
开发者ID:reliv,项目名称:rcm,代码行数:36,代码来源:PluginManager.php

示例15: 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


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