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


PHP CacheProvider::contains方法代码示例

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


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

示例1: get

 /**
  * @param string $key
  * @return mixed|null
  */
 public function get($key)
 {
     if (!$this->cache->contains($key)) {
         $this->loadSettings();
     }
     return $this->cache->fetch($key);
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:11,代码来源:SettingsProvider.php

示例2: getVersion

 /**
  * @param string $packageName
  * @return string
  */
 public function getVersion($packageName = OroPlatformBundle::PACKAGE_NAME)
 {
     // Get package version from local cache if any
     if (isset($this->packageVersions[$packageName])) {
         return $this->packageVersions[$packageName];
     }
     // Try to get package version from persistent cache
     if ($this->cache && $this->cache->contains($packageName)) {
         $version = $this->cache->fetch($packageName);
     } else {
         // Get package version from composer repository
         $packages = $this->factory->getLocalRepository()->findPackages($packageName);
         if ($package = current($packages)) {
             /** @var PackageInterface $package */
             $version = $package->getPrettyVersion();
         } else {
             $version = self::UNDEFINED_VERSION;
         }
         //Save package version to persistent cache
         if ($this->cache) {
             $this->cache->save($packageName, $version);
         }
     }
     // Save package version to local cache
     $this->packageVersions[$packageName] = $version;
     return $version;
 }
开发者ID:Maksold,项目名称:platform,代码行数:31,代码来源:VersionHelper.php

示例3: get

 /**
  * Build menu.
  *
  * @param  string        $alias
  * @param  array         $options
  * @return ItemInterface
  */
 public function get($alias, array $options = [])
 {
     $this->assertAlias($alias);
     if (!array_key_exists($alias, $this->menus)) {
         if ($this->cache && $this->cache->contains($alias)) {
             $menuData = $this->cache->fetch($alias);
             $this->menus[$alias] = $this->factory->createFromArray($menuData);
         } else {
             $menu = $this->factory->createItem($alias);
             /** @var BuilderInterface $builder */
             // try to find builder for the specified menu alias
             if (array_key_exists($alias, $this->builders)) {
                 foreach ($this->builders[$alias] as $builder) {
                     $builder->build($menu, $options, $alias);
                 }
             }
             // In any case we must run common builder
             if (array_key_exists(self::COMMON_BUILDER_ALIAS, $this->builders)) {
                 foreach ($this->builders[self::COMMON_BUILDER_ALIAS] as $builder) {
                     $builder->build($menu, $options, $alias);
                 }
             }
             $this->menus[$alias] = $menu;
             $this->eventDispatcher->dispatch(ConfigureMenuEvent::getEventName($alias), new ConfigureMenuEvent($this->factory, $menu));
             $this->sort($menu);
             if ($this->cache) {
                 $this->cache->save($alias, $menu->toArray());
             }
         }
     }
     return $this->menus[$alias];
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:39,代码来源:BuilderChainProvider.php

示例4: isRated

 /**
  * @param Article $article
  * @return bool
  */
 public function isRated(Article $article)
 {
     $ip = $this->getRequest()->getClientIp();
     if ($this->cache->contains($ip)) {
         return true;
     }
     return $this->isLiked($article) || $this->isDisLiked($article);
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:12,代码来源:Rating.php

示例5: deleteItems

 /**
  * {@inheritdoc}
  */
 public function deleteItems(array $keys)
 {
     foreach ($keys as $key) {
         if (true === $this->provider->contains($key)) {
             $this->provider->delete($key);
         }
     }
     return $this;
 }
开发者ID:shieldo,项目名称:Cache,代码行数:12,代码来源:DoctrineCacheAdapter.php

示例6: __construct

 /**
  * @param \Doctrine\Common\Cache\CacheProvider $cacheDriver
  */
 public function __construct($cacheDriver = null)
 {
     if (!is_null($cacheDriver) && class_exists('\\Doctrine\\Common\\Cache\\CacheProvider')) {
         if ($cacheDriver instanceof \Doctrine\Common\Cache\CacheProvider) {
             $this->cacheDriver = $cacheDriver;
             if ($this->cacheDriver->contains($this->cacheKey)) {
                 $this->data = $this->cacheDriver->fetch($this->cacheKey);
             }
         }
     }
 }
开发者ID:teknomavi,项目名称:tcmb,代码行数:14,代码来源:Doviz.php

示例7: preFind

 /**
  * @param EventInterface $event
  */
 public function preFind(EventInterface $event)
 {
     if (!preg_match('/\\d$/', $this->cacheId)) {
         return;
         //The current route is a POST, do not cache new resources with this cache ID
     }
     if ($this->cache->contains($this->cacheId)) {
         $event->stopPropagation(true);
         return $this->cache->fetch($this->cacheId);
     }
 }
开发者ID:comphppuebla,项目名称:restful-extensions,代码行数:14,代码来源:CacheListener.php

示例8: loadSourceData

 /**
  * @return array
  */
 public function loadSourceData()
 {
     if (null === $this->cache) {
         return $this->formatDataLoader->load($this->getUrl());
     }
     $key = $this->getObjectKey();
     if (!$this->cache->contains($key)) {
         $this->cache->save($key, $this->formatDataLoader->load($this->getUrl()), $this->getTtl());
     }
     return $this->cache->fetch($key);
 }
开发者ID:slavamuravey,项目名称:leaderboard-bundle,代码行数:14,代码来源:DataLoader.php

示例9: testInvalidate

 public function testInvalidate()
 {
     $key = 'test';
     // create a fake list
     $this->cache->register($key, uniqid());
     $this->cache->register($key, uniqid());
     $this->ormCache->save($key, 'bar');
     $this->cache->invalidate($key);
     // now both the orm cache and our cache should not contain this list
     $this->assertFalse($this->ormCache->contains($key));
     $this->assertNotContains($key, $this->cache->getRegisteredKeys($key));
 }
开发者ID:treehouselabs,项目名称:cache-bundle,代码行数:12,代码来源:EntityCacheTest.php

示例10: call

 public function call()
 {
     if (!in_array($this->app->request()->getMethod(), ['GET', 'HEAD'])) {
         return $this->next->call();
     }
     $cacheKey = $this->app->request()->getPathInfo();
     if ($this->cache->contains($cacheKey)) {
         $resource = $this->cache->fetch($cacheKey);
         $lastModified = strtotime($resource['last_updated_at']);
         $this->app->lastModified($lastModified);
     }
     $this->next->call();
 }
开发者ID:comphppuebla,项目名称:restful-extensions,代码行数:13,代码来源:HttpCacheMiddleware.php

示例11: get

 /**
  * @return string
  */
 public function get()
 {
     $key = 'feed';
     if ($this->cache->contains($key)) {
         return $this->cache->fetch($key);
     }
     $articles = $this->articleRepository->findPublishedOrderedByPublishDate();
     $feed = $this->feedManager->get('article');
     $feed->addFromArray($articles);
     $renderedFeed = $feed->render('rss');
     $this->cache->save($key, $renderedFeed);
     return $renderedFeed;
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:16,代码来源:Feed.php

示例12: getAll

 /**
  * @return array
  */
 public function getAll()
 {
     $key = 'statistics';
     if ($this->cache->contains($key)) {
         return $this->cache->fetch($key);
     }
     $statistics = $this->articleRepository->findStatistics();
     $mostPopularArticle = $this->articleRepository->findMostPopular();
     if ($mostPopularArticle) {
         $statistics['mostPopularArticleData'] = ['slug' => $mostPopularArticle->getSlug(), 'title' => $mostPopularArticle->getTitle(), 'viewsCount' => $mostPopularArticle->getViewsCount()];
     }
     $this->cache->save($key, $statistics, $this->cacheLifetime);
     return $statistics;
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:17,代码来源:Statistics.php

示例13: checkDeploy

 public function checkDeploy(GetResponseEvent $event)
 {
     if (null === $this->cache || $this->cache->contains(self::CHECK_DEPLOY_KEY)) {
         return;
     }
     $clients = $this->clientRepository->countClients();
     $cities = $this->cityRepository->countCities();
     $hasDefaultClient = $this->clientRepository->findOneByUid($this->defaultClientUid) instanceof Client;
     if ($clients <= 0 || $cities <= 0 || !$hasDefaultClient) {
         $this->cache->delete(self::CHECK_DEPLOY_KEY);
         throw new \RuntimeException('Make sure you did run the populate database command.');
     } else {
         $this->cache->save(self::CHECK_DEPLOY_KEY, true);
     }
 }
开发者ID:redelivre,项目名称:login-cidadao,代码行数:15,代码来源:CheckDeployEventSubscriber.php

示例14: process

 /**
  *
  * @param string $name
  * @param string $processor
  * @param \Heyday\CacheInclude\KeyCreators\KeyCreatorInterface $keyCreator
  * @throws \InvalidArgumentException
  * @return mixed
  */
 public function process($name, $processor, KeyCreatorInterface $keyCreator)
 {
     if (!$processor instanceof ProcessorInterface && !is_callable($processor)) {
         throw new \InvalidArgumentException('The argument $processor must be an instance of ProcessorInterface or a callable');
     }
     if (!$this->enabled) {
         return $processor($name);
     }
     $config = $this->getCombinedConfig($name);
     $key = $this->getKey($name, $keyCreator, $config);
     if ($this->forceExpire) {
         $this->cache->delete($key);
         $this->removeStoredKey($name, $key);
         $result = $processor($name);
         $type = "EXPIRE";
     } elseif ($this->cache->contains($key)) {
         $result = $this->cache->fetch($key);
         $type = "HIT";
     } else {
         $this->cache->save($key, $result = $processor($name), $this->getExpiry($config));
         $this->addStoredKey($name, $key, $keyCreator);
         $type = "MISS";
     }
     $this->log($type, $name, $key);
     return $result;
 }
开发者ID:Focus-Flow,项目名称:silverstripe-cacheinclude,代码行数:34,代码来源:CacheInclude.php

示例15: contains

 /**
  * Returns a boolean state of whether or not the item exists in the cache based on id key
  *
  * @param string $id    the id of the cached data entry
  * @return bool         true if the cached items exists
  */
 public function contains($id)
 {
     if ($this->enabled) {
         return $this->driver->contains($id);
     }
     return false;
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:13,代码来源:Cache.php


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