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


PHP Cache\CacheProvider类代码示例

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


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

示例1: __construct

 /**
  * @param string $file
  * @param \Doctrine\Common\Cache\CacheProvider $cache
  * @throws \Heystack\Core\Exception\ConfigurationException
  */
 public function __construct($file, CacheProvider $cache)
 {
     // if it isn't an absolute path (detected by the file not existing)
     if (!file_exists($file)) {
         $file = BASE_PATH . '/' . $file;
     }
     if (!file_exists($file)) {
         throw new ConfigurationException(sprintf("Your file '%s' doesn't exist", $file));
     }
     // Use the contents as the key so invalidation happens on change
     $key = md5(file_get_contents($file));
     if (($config = $cache->fetch($key)) === false) {
         $config = $this->parseFile($file);
         $cache->save($key, $config);
     }
     if (!is_array($config)) {
         throw new ConfigurationException(sprintf("Your config is empty for file '%s'", $file));
     }
     if (!array_key_exists('id', $config)) {
         throw new ConfigurationException(sprintf("Identifier missing for file '%s'", $file));
     }
     if (!array_key_exists('flat', $config)) {
         throw new ConfigurationException(sprintf("Flat config missing for file '%s'", $file));
     }
     $this->config = $config;
 }
开发者ID:helpfulrobot,项目名称:heystack-heystack,代码行数:31,代码来源:FileDataObjectSchema.php

示例2: decorateWithConnectable

 /**
  * @param CacheProvider $cacheProvider
  *
  * @return CacheProvider
  */
 protected function decorateWithConnectable(CacheProvider $cacheProvider)
 {
     $memcached = $this->getMemcachedAdapter();
     $settings = $this->config->getSettings();
     $memcached->addserver($settings['host'], $settings['port']);
     $cacheProvider->setMemcached($memcached);
     return $cacheProvider;
 }
开发者ID:pcelta,项目名称:doctrine-cache-factory,代码行数:13,代码来源:MemcachedFactory.php

示例3: clearCacheDriver

 protected function clearCacheDriver(CacheProvider $cacheDriver = null, $description = "")
 {
     if ($cacheDriver !== null) {
         $this->output .= 'Doctrine ' . $description . ' cache: ' . $cacheDriver->getNamespace() . ' — ';
         $this->output .= $cacheDriver->deleteAll() ? '<info>OK</info>' : '<info>FAIL</info>';
         $this->output .= PHP_EOL;
     }
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:8,代码来源:DoctrineCacheClearer.php

示例4: decorateWithConnectable

 /**
  * @param CacheProvider $cacheProvider
  *
  * @return CacheProvider
  */
 protected function decorateWithConnectable(CacheProvider $cacheProvider)
 {
     $redis = $this->getRedisAdapter();
     $settings = $this->config->getSettings();
     $redis->connect($settings['host'], $settings['port']);
     $cacheProvider->setRedis($redis);
     return $cacheProvider;
 }
开发者ID:pcelta,项目名称:doctrine-cache-factory,代码行数:13,代码来源:RedisFactory.php

示例5: __construct

 /**
  * Constructor
  *
  * $injector       function () {return Injector::create([new Module])};
  * $initialization  function ($instance, InjectorInterface $injector) {};
  *
  * @param callable             $injector
  * @param callable             $initialization
  * @param string               $cacheNamespace
  * @param CacheProvider        $cache
  * @param ClassLoaderInterface $classLoader
  */
 public function __construct(callable $injector, callable $initialization, $cacheNamespace, CacheProvider $cache, ClassLoaderInterface $classLoader = null)
 {
     $this->injector = $injector;
     $this->initialization = $initialization;
     $this->cacheNamespace = $cacheNamespace;
     $this->cache = $cache;
     $cache->setNamespace($cacheNamespace);
     $this->cache = $cache;
     $this->classLoader = $classLoader ?: new AopClassLoader();
 }
开发者ID:lucatume,项目名称:php-dependency-injection-benchmarks,代码行数:22,代码来源:CacheInjector.php

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

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

示例8: loadSettings

 /**
  * @return array
  */
 private function loadSettings()
 {
     /** @var Setting $setting */
     foreach ($this->repository->findAll() as $setting) {
         $this->cache->save($setting->getKey(), $setting->getValue());
     }
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:10,代码来源:SettingsProvider.php

示例9: clearCache

 /**
  *
  */
 private function clearCache()
 {
     $container = $this->getConfigurationPool()->getContainer();
     $container->get('harentius_blog.router.category_slug_provider')->clearAll();
     $this->cache->deleteAll();
     $container->get('harentius_blog.controller.feed_cache')->deleteAll();
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:10,代码来源:ArticleAdmin.php

示例10: clean

 /**
  * Removes items from the cache by conditions.
  *
  * @param array $conditions
  * @return void
  */
 public function clean(array $conditions)
 {
     if (!isset($conditions[Nette\Caching\Cache::ALL])) {
         throw new NotImplementedException();
     }
     $this->provider->deleteAll();
 }
开发者ID:Richmond77,项目名称:learning-nette,代码行数:13,代码来源:ReversedStorageDecorator.php

示例11: getTcmbData

 /**
  * TCMB sitesi üzerinden XML'i okur.
  *
  * @param Curl $curl
  *
  * @throws Exception\ConnectionFailed
  */
 private function getTcmbData(Curl $curl = null)
 {
     if (is_null($curl)) {
         $curl = new Curl();
     }
     $curl->setOption(CURLOPT_URL, 'http://www.tcmb.gov.tr/kurlar/today.xml');
     $curl->setOption(CURLOPT_HEADER, 0);
     $curl->setOption(CURLOPT_RETURNTRANSFER, 1);
     $curl->setOption(CURLOPT_FOLLOWLOCATION, 1);
     $response = $curl->exec();
     if ($response === false) {
         throw new Exception\ConnectionFailed('Sunucu Bağlantısı Kurulamadı: ' . $curl->error());
     }
     $curl->close();
     $this->data = $this->formatTcmbData((array) simplexml_load_string($response));
     $timezone = new \DateTimeZone('Europe/Istanbul');
     $now = new \DateTime('now', $timezone);
     $expire = $this->data['today'] == $now->format('d.m.Y') ? 'Tomorrow 15:30' : 'Today 15:30';
     $expireDate = new \DateTime($expire, $timezone);
     $this->data['expire'] = $expireDate->getTimestamp();
     if (!is_null($this->cacheDriver)) {
         $lifetime = $expire - $now->getTimestamp();
         // Eğer dosyanın geçerlilik süresi bitmişse veriyi sadece 5 dakika önbellekte tutuyoruz.
         $this->cacheDriver->save($this->cacheKey, $this->data, $lifetime > 0 ? $lifetime : 300);
     }
 }
开发者ID:teknomavi,项目名称:tcmb,代码行数:33,代码来源:Doviz.php

示例12: clear

 public function clear()
 {
     if (!$this->hasNamespace()) {
         $this->doctrineCache->flushAll();
     } else {
         $this->withNamespace()->deleteAll();
     }
 }
开发者ID:timetoogo,项目名称:pinq,代码行数:8,代码来源:DoctrineCache.php

示例13: build

 /**
  * (non-PHPdoc)
  * @see Generator/Admingenerator\GeneratorBundle\Generator.GeneratorInterface::build()
  */
 public function build()
 {
     if ($this->cacheProvider->fetch($this->getCacheKey())) {
         return;
     }
     $this->doBuild();
     $this->cacheProvider->save($this->getCacheKey(), true);
 }
开发者ID:amacrobert-meq,项目名称:AdmingeneratorGeneratorBundle,代码行数:12,代码来源:Generator.php

示例14: getCachedAssetVersion

 /**
  * @param string $packageName
  *
  * @return int
  */
 protected function getCachedAssetVersion($packageName)
 {
     if (!array_key_exists($packageName, $this->localCache)) {
         $version = $this->cache->fetch($packageName);
         $this->localCache[$packageName] = false !== $version ? $version : 0;
     }
     return $this->localCache[$packageName];
 }
开发者ID:ramunasd,项目名称:platform,代码行数:13,代码来源:DynamicAssetVersionManager.php

示例15: FetchWithNamespace_StoreInformation

 /**
  * @test
  */
 public function FetchWithNamespace_StoreInformation()
 {
     $this->cacheProvider->save('namespaceId', 'namespace_id');
     $this->cacheProvider->save('namespace_idid', 'data-test');
     $this->decorator->fetchWithNamespace('id', 'namespaceId');
     $this->decorator->fetchWithNamespace('id', 'namespaceId');
     $this->assertCollectedData([new FetchWithNamespaceCacheCollectedData('id', 'namespaceId', 'data-test', 0)], $this->decorator->getCollectedData());
 }
开发者ID:emilyreese,项目名称:DoctrineCacheExtensionBundle,代码行数:11,代码来源:DebugCacheProviderDecoratorTest.php


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