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


PHP StorageInterface::removeItem方法代码示例

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


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

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

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

示例3: setDelayedItem

 public function setDelayedItem($key, Closure $closure)
 {
     $this->storage->setItem($this->getDelayedKey($key), self::UNDER_CONSTRUCTION_VALUE);
     $setReturn = $this->storage->setItem($key, $closure());
     $this->storage->removeItem($this->getDelayedKey($key));
     return $setReturn;
 }
开发者ID:nasimnabavi,项目名称:DelayedCache,代码行数:7,代码来源:DelayedCache.php

示例4: callWidget

 /**
  * Call widget
  *
  * @param string $position
  * @param integer $pageId
  * @param integer $userRole
  * @param array $widgetInfo
  * @param boolean $useLayout
  * @throws \Page\Exception\PageException
  * @return string|boolean
  */
 protected function callWidget($position, $pageId, $userRole, array $widgetInfo, $useLayout = true)
 {
     // don't call any widgets
     if (true === self::$widgetRedirected) {
         return false;
     }
     // check a widget visibility
     if ($userRole != AclBaseModel::DEFAULT_ROLE_ADMIN) {
         if (!empty($widgetInfo['hidden']) && in_array($userRole, $widgetInfo['hidden'])) {
             return false;
         }
     }
     // call the widget
     $widget = $this->getView()->{$widgetInfo['widget_name']}();
     // check the widget
     if (!$widget instanceof IPageWidget) {
         throw new PageException(sprintf($widgetInfo['widget_name'] . ' must be an object implementing IPageWidget'));
     }
     // init the widget
     $widget->setPageId($pageId)->setWidgetPosition($position)->setWidgetConnectionId($widgetInfo['widget_connection_id']);
     $widgetCacheName = null;
     if ((int) $widgetInfo['widget_cache_ttl']) {
         // generate a cache name
         $widgetCacheName = CacheUtility::getCacheName($widgetInfo['widget_name'], [$widgetInfo['widget_connection_id']]);
         // check the widget data in a cache
         if (null !== ($cachedWidgetData = $this->dynamicCache->getItem($widgetCacheName))) {
             // check a local widget lifetime
             if ($cachedWidgetData['widget_expire'] >= time()) {
                 // include widget's css and js files
                 if (false !== $cachedWidgetData['widget_content'] && !$this->request->isXmlHttpRequest()) {
                     $widget->includeJsCssFiles();
                 }
                 return $cachedWidgetData['widget_content'];
             }
             // clear cache
             $this->dynamicCache->removeItem($widgetCacheName);
         }
     }
     if (false !== ($widgetContent = $widget->getContent())) {
         self::$widgetRedirected = $widget->isWidgetRedirected();
         // include widget's css and js files
         if (!$this->request->isXmlHttpRequest()) {
             $widget->includeJsCssFiles();
         }
         // add the widget's layout
         if ($useLayout) {
             if (!empty($widgetInfo['widget_layout'])) {
                 $widgetContent = $this->getView()->partial($this->layoutPath . $widgetInfo['widget_layout'], ['title' => $this->getView()->pageWidgetTitle($widgetInfo), 'content' => $widgetContent]);
             } else {
                 $widgetContent = $this->getView()->partial($this->layoutPath . 'default', ['title' => $this->getView()->pageWidgetTitle($widgetInfo), 'content' => $widgetContent]);
             }
         }
     }
     // cache the widget data
     if ($widgetCacheName) {
         $this->dynamicCache->setItem($widgetCacheName, ['widget_content' => $widgetContent, 'widget_expire' => time() + $widgetInfo['widget_cache_ttl']]);
     }
     return $widgetContent;
 }
开发者ID:esase,项目名称:dream-cms,代码行数:70,代码来源:PageInjectWidget.php

示例5: removeCachedData

 /**
  * Helper function for removing cached data.
  *
  * @param string $key Cache entry key
  *
  * @return void
  */
 protected function removeCachedData($key)
 {
     // Don't write to cache if we don't have a cache!
     if (null === $this->cache) {
         return;
     }
     $this->cache->removeItem($this->formatCacheKey($key));
 }
开发者ID:datavoyager,项目名称:vufind,代码行数:15,代码来源:AbstractBase.php

示例6: releaseLock

 /**
  * Release lock
  *
  * @param  string $name name of lock
  * @return bool
  */
 public function releaseLock($name)
 {
     if (isset($this->locks[$name])) {
         $this->cache->removeItem($name);
         return true;
     }
     return false;
 }
开发者ID:wshafer,项目名称:ninja-mutex-zf2,代码行数:14,代码来源:ZendCacheLock.php

示例7: onKernelRequest

 /**
  * Triggered before controller call
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST && $request->isMethodSafe()) {
         $key = $this->getKeyFromRequest($request);
         // If no cache request header exists - clear cache
         if ($request->isNoCache()) {
             $this->storage->removeItem($key);
         }
         // If response exists in cache - restore it and set back to event
         if ($this->storage->hasItem($key)) {
             $data = $this->storage->getItem($key);
             $response = new Response($data['content'], $data['status'], $data['headers']);
             $response->prepare($request);
             $response->isNotModified($request);
             $event->setResponse($response);
         }
     }
 }
开发者ID:sunnyct,项目名称:silexcmf,代码行数:24,代码来源:HttpKernelListener.php

示例8: canSetDelayedItemReturnsAdapter

 /**
  * @test
  */
 public function canSetDelayedItemReturnsAdapter()
 {
     $this->storage->setItem($this->delayedKey, 'under_construction')->shouldBeCalled();
     $this->storage->removeItem($this->delayedKey)->shouldBeCalled();
     $this->storage->setItem('foo', 'bar')->willReturn(true);
     $return = $this->cache->setDelayedItem('foo', function () {
         return 'bar';
     });
     $this->assertSame(true, $return);
 }
开发者ID:koinephp,项目名称:DelayedCache,代码行数:13,代码来源:DelayedCacheTest.php

示例9: deleteItem

 /**
  * Removes the item from the pool.
  *
  * @param string $key
  *   The key for which to delete
  *
  * @throws InvalidArgumentException
  *   If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
  *   MUST be thrown.
  *
  * @return bool
  *   True if the item was successfully removed. False if there was an error.
  */
 public function deleteItem($key)
 {
     $this->validateKey($key);
     try {
         $deleted = $this->storage->removeItem($key);
     } 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 $deleted;
 }
开发者ID:Nyholm,项目名称:zend-cache-psr6,代码行数:25,代码来源:CacheItemPoolAdapter.php

示例10: setDelayedItem

 public function setDelayedItem($key, Closure $closure)
 {
     try {
         $delayedKey = $this->getDelayedKey($key);
         $this->storage->setItem($this->getDelayedKey($key), self::UNDER_CONSTRUCTION_VALUE);
         $setReturn = $this->storage->setItem($key, $closure());
         $this->storage->removeItem($delayedKey);
         return $setReturn;
     } catch (\Exception $exception) {
         $this->storage->removeItem($delayedKey);
         throw $exception;
     }
 }
开发者ID:koinephp,项目名称:DelayedCache,代码行数:13,代码来源:DelayedCache.php

示例11: getCachedData

 /**
  * Helper function for fetching cached data.
  * Data is cached for up to $this->cacheLifetime seconds so that it would be
  * faster to process e.g. requests where multiple calls to the backend are made.
  *
  * @param string $key Cache entry key
  *
  * @return mixed|null Cached entry or null if not cached or expired
  */
 protected function getCachedData($key)
 {
     // No cache object, no cached results!
     if (null === $this->cache) {
         return null;
     }
     $fullKey = $this->formatCacheKey($key);
     $item = $this->cache->getItem($fullKey);
     if (null !== $item) {
         // Return value if still valid:
         if (time() - $item['time'] < $this->cacheLifetime) {
             return $item['entry'];
         }
         // Clear expired item from cache:
         $this->cache->removeItem($fullKey);
     }
     return null;
 }
开发者ID:grharry,项目名称:vufind,代码行数:27,代码来源:AbstractBase.php

示例12: clearPageItemCache

 /**
  * Clear the page item cache.
  *
  * @param int $pageNumber
  * @return Paginator
  */
 public function clearPageItemCache($pageNumber = null)
 {
     if (!$this->cacheEnabled()) {
         return $this;
     }
     if (null === $pageNumber) {
         $prefixLength = strlen(self::CACHE_TAG_PREFIX);
         $cacheIterator = static::$cache->getIterator();
         $cacheIterator->setMode(CacheIterator::CURRENT_AS_KEY);
         foreach ($cacheIterator as $key) {
             if (substr($key, 0, $prefixLength) == self::CACHE_TAG_PREFIX) {
                 static::$cache->removeItem($this->_getCacheId((int) substr($key, $prefixLength)));
             }
         }
     } else {
         $cleanId = $this->_getCacheId($pageNumber);
         static::$cache->removeItem($cleanId);
     }
     return $this;
 }
开发者ID:robertboloc,项目名称:zf2,代码行数:26,代码来源:Paginator.php

示例13: testRemoveItemReturnsFalseOnMissingItem

 public function testRemoveItemReturnsFalseOnMissingItem()
 {
     $this->assertFalse($this->_storage->removeItem('missing'));
 }
开发者ID:ninahuanca,项目名称:zf2,代码行数:4,代码来源:CommonAdapterTest.php

示例14: purge

 public function purge($url)
 {
     return $this->storageCache->removeItem($this->buildKey($url));
 }
开发者ID:solcre,项目名称:columnis-express,代码行数:4,代码来源:ZfCacheAdapter.php

示例15: remove

 /**
  * {@inheritDoc}
  */
 public function remove($key)
 {
     return $this->zendCache->removeItem($key);
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:7,代码来源:ZendCacheAdapter.php


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