• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Cache\CacheProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了CacheProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: setUp

 protected function setUp()
 {
     $this->cache = $this->getMockForAbstractClass('Doctrine\\Common\\Cache\\CacheProvider');
     $this->cache->expects($this->any())->method('fetch')->will($this->returnValue(false));
     $this->cache->expects($this->any())->method('save');
     $this->ownershipMetadataProvider = $this->getMockBuilder('OroB2B\\Bundle\\CustomerBundle\\Owner\\Metadata\\FrontendOwnershipMetadataProvider')->disableOriginalConstructor()->getMock();
     $this->managerRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
     $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->container->expects($this->any())->method('get')->willReturnMap([['orob2b_customer.owner.frontend_ownership_tree_provider.cache', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->cache], ['orob2b_customer.owner.frontend_ownership_metadata_provider', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->ownershipMetadataProvider], ['doctrine', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->managerRegistry], ['oro_security.security_facade', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->securityFacade]]);
     $this->treeProvider = new FrontendOwnerTreeProvider();
     $this->treeProvider->setContainer($this->container);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:13,代码来源:FrontendOwnerTreeProviderTest.php


示例7: setCacheProvider

 /**
  * @param CacheProvider $cacheProvider
  */
 public function setCacheProvider($cacheProvider)
 {
     $namespace = '[<>]' . rtrim($this->getName() . '|' . $cacheProvider->getNamespace(), '|') . '[<>]';
     $arrayCache = new ArrayCache();
     $cacheChain = new ChainCache([$arrayCache, $cacheProvider]);
     $cacheProvider = new Wrapper($cacheChain);
     $cacheProvider->setNamespace($namespace);
     $this->cacheProvider = $cacheProvider;
     $this->readConnection->setCacheProvider($cacheProvider);
     if ($this->writeConnection) {
         $this->writeConnection->setCacheProvider($cacheProvider);
     }
 }
开发者ID:nhagemann,项目名称:anycontent-client-php,代码行数:16,代码来源:CachingRepository.php


示例8: setUp

 protected function setUp()
 {
     $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $managerRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $managerRegistry->expects($this->any())->method('getManagerForClass')->willReturn($this->em);
     $this->cache = $this->getMockForAbstractClass('Doctrine\\Common\\Cache\\CacheProvider');
     $this->cache->expects($this->any())->method('fetch')->will($this->returnValue(false));
     $this->cache->expects($this->any())->method('save');
     $this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
     $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->container->expects($this->any())->method('get')->will($this->returnValueMap([['oro_security.ownership_tree_provider.cache', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->cache], ['oro_security.owner.ownership_metadata_provider', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, new OwnershipMetadataProviderStub($this, ['user' => 'Oro\\Bundle\\UserBundle\\Entity\\User', 'business_unit' => 'Oro\\Bundle\\OrganizationBundle\\Entity\\BusinessUnit'])], ['doctrine', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $managerRegistry], ['oro_security.security_facade', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->securityFacade]]));
     $this->treeProvider = new OwnerTreeProvider($this->em, $this->cache);
     $this->treeProvider->setContainer($this->container);
 }
开发者ID:northdakota,项目名称:platform,代码行数:14,代码来源:OwnerTreeProviderTest.php


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


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


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


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


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


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


示例15: clear

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


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


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


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


示例19: get

 /**
  * {@inheritdoc}
  */
 public function get(RequesterInterface $requester, ResourceInterface $resource)
 {
     $cacheId = $this->getCacheId($requester, $resource);
     $permission = $this->cacheProvider->fetch($cacheId);
     if ($permission instanceof PermissionInterface) {
         return $permission;
     }
     $this->cacheProvider->delete($cacheId);
     return;
 }
开发者ID:alexdpy,项目名称:acl,代码行数:13,代码来源:PermissionBuffer.php


示例20: updateTimestamp

 /**
  * Renews the timestamp of the last update of database translations for the given locale
  *
  * @param string|null $locale
  */
 public function updateTimestamp($locale = null)
 {
     if ($locale) {
         $this->localCache[$locale] = (new \DateTime('now', new \DateTimeZone('UTC')))->getTimestamp();
         $this->cacheImpl->save($locale, $this->localCache[$locale]);
     } else {
         $this->localCache = [];
         $this->cacheImpl->deleteAll();
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:DynamicTranslationMetadataCache.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Collections\ArrayCollection类代码示例发布时间:2022-05-23
下一篇:
PHP Cache\Cache类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap