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


PHP Cache::engine方法代码示例

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


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

示例1: testTranslationCaching

 /**
  * testTranslationCaching method
  *
  * @return void
  */
 public function testTranslationCaching()
 {
     $this->skipIf(!Cache::engine('_cake_core_'), 'Missing _cake_core_ cache config, cannot test caching.');
     Configure::write('Config.language', 'cache_test_po');
     // reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     $lang = Configure::read('Config.language');
     // make some calls to translate using different domains
     $this->assertEquals('Dom 1 Foo', I18n::translate('dom1.foo', false, 'dom1'));
     $this->assertEquals('Dom 1 Bar', I18n::translate('dom1.bar', false, 'dom1'));
     $domains = I18n::domains();
     $this->assertEquals('Dom 1 Foo', $domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo']);
     // reset internally stored entries
     I18n::clear();
     // now only dom1 should be in cache
     $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
     $this->assertEquals('Dom 1 Foo', $cachedDom1['LC_MESSAGES']['dom1.foo']);
     $this->assertEquals('Dom 1 Bar', $cachedDom1['LC_MESSAGES']['dom1.bar']);
     // dom2 not in cache
     $this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
     // translate a item of dom2 (adds dom2 to cache)
     $this->assertEquals('Dom 2 Foo', I18n::translate('dom2.foo', false, 'dom2'));
     // verify dom2 was cached through manual read from cache
     $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
     $this->assertEquals('Dom 2 Foo', $cachedDom2['LC_MESSAGES']['dom2.foo']);
     $this->assertEquals('Dom 2 Bar', $cachedDom2['LC_MESSAGES']['dom2.bar']);
     // modify cache entry manually to verify that dom1 entries now will be read from cache
     $cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
     Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
     $this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1'));
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:37,代码来源:I18nTest.php

示例2: testConfig

 /**
  * testConfig method
  *
  * @return void
  */
 public function testConfig()
 {
     $config = Cache::engine('xcache')->config();
     $expecting = ['prefix' => 'cake_', 'duration' => 3600, 'probability' => 100];
     $this->assertTrue(isset($config['PHP_AUTH_USER']));
     $this->assertTrue(isset($config['PHP_AUTH_PW']));
     unset($config['PHP_AUTH_USER'], $config['PHP_AUTH_PW']);
     $this->assertEquals($config, $expecting);
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:14,代码来源:XcacheEngineTest.php

示例3: testInitializeTwiceNoDoubleProxy

 /**
  * Ensure that subrequests don't double proxy the cache engine.
  *
  * @return void
  */
 public function testInitializeTwiceNoDoubleProxy()
 {
     $event = new Event('Sample');
     $this->panel->initialize($event);
     $result = Cache::engine('debug_kit_test');
     $this->assertInstanceOf('DebugKit\\Cache\\Engine\\DebugEngine', $result);
     $this->panel->initialize($event);
     $result2 = Cache::engine('debug_kit_test');
     $this->assertSame($result2, $result);
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:15,代码来源:CachePanelTest.php

示例4: translators

 /**
  * Returns the translators collection instance. It can be used
  * for getting specific translators based of their name and locale
  * or to configure some aspect of future translations that are not yet constructed.
  *
  * @return \Aura\Intl\TranslatorLocator The translators collection.
  */
 public static function translators()
 {
     if (static::$_collection !== null) {
         return static::$_collection;
     }
     static::$_collection = new TranslatorRegistry(new PackageLocator(), new FormatterLocator(['sprintf' => function () {
         return new SprintfFormatter();
     }, 'default' => function () {
         return new IcuFormatter();
     }]), new TranslatorFactory(), static::locale());
     if (class_exists('Cake\\Cache\\Cache')) {
         static::$_collection->setCacher(Cache::engine('_cake_core_'));
     }
     return static::$_collection;
 }
开发者ID:thanghexp,项目名称:project,代码行数:22,代码来源:I18n.php

示例5: clear

 /**
  * Clear metadata.
  *
  * @param string|null $prefix The cache prefix to be cleared.
  * @throws \Cake\Console\Exception\StopException
  * @return void
  */
 public function clear($prefix = null)
 {
     try {
         $engine = Cache::engine($prefix);
         Cache::clear(false, $prefix);
         if ($engine instanceof ApcEngine) {
             $this->warn("ApcEngine detected: Cleared {$prefix} CLI cache successfully " . "but {$prefix} web cache must be cleared separately.");
         } elseif ($engine instanceof WincacheEngine) {
             $this->warn("WincacheEngine detected: Cleared {$prefix} CLI cache successfully " . "but {$prefix} web cache must be cleared separately.");
         } else {
             $this->out("<success>Cleared {$prefix} cache</success>");
         }
     } catch (\InvalidArgumentException $e) {
         $this->abort($e->getMessage());
     }
 }
开发者ID:nrother,项目名称:cakephp,代码行数:23,代码来源:CacheShell.php

示例6: testConfig

 /**
  * testConfig method
  *
  * @return void
  */
 public function testConfig()
 {
     $config = Cache::engine('memcached')->config();
     unset($config['path']);
     $expecting = ['prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, 'servers' => ['127.0.0.1'], 'persistent' => false, 'compress' => false, 'username' => null, 'password' => null, 'groups' => [], 'serialize' => 'php', 'options' => [], 'host' => null, 'port' => null];
     $this->assertEquals($expecting, $config);
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:12,代码来源:MemcachedEngineTest.php

示例7: _resolveCacher

 /**
  * Get the cache engine.
  *
  * @return \Cake\Cache\CacheEngine
  */
 protected function _resolveCacher()
 {
     if (is_string($this->_config)) {
         return Cache::engine($this->_config);
     }
     return $this->_config;
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:12,代码来源:QueryCacher.php

示例8: testConnect

 /**
  * testConnect method
  *
  * @return void
  */
 public function testConnect()
 {
     $Redis = new RedisEngine();
     $this->assertTrue($Redis->init(Cache::engine('redis')->config()));
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:10,代码来源:RedisEngineTest.php

示例9: testDrop

 /**
  * test that drop removes cache configs, and that further attempts to use that config
  * do not work.
  *
  * @return void
  */
 public function testDrop()
 {
     Configure::write('App.namespace', 'TestApp');
     $result = Cache::drop('some_config_that_does_not_exist');
     $this->assertFalse($result, 'Drop should not succeed when config is missing.');
     Cache::config('unconfigTest', ['engine' => 'TestAppCache']);
     $this->assertInstanceOf('TestApp\\Cache\\Engine\\TestAppCacheEngine', Cache::engine('unconfigTest'));
     $this->assertTrue(Cache::drop('unconfigTest'));
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:15,代码来源:CacheTest.php

示例10: testConfig

 /**
  * testConfig method
  *
  * @return void
  */
 public function testConfig()
 {
     $config = Cache::engine('memcached')->config();
     unset($config['path']);
     $expecting = array('prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, 'servers' => array('127.0.0.1'), 'persistent' => false, 'compress' => false, 'login' => null, 'password' => null, 'groups' => array(), 'serialize' => 'php');
     $this->assertEquals($expecting, $config);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:12,代码来源:MemcachedEngineTest.php

示例11: __construct

 /**
  * Constructor
  *
  * @param string $alias Cache name alias.
  */
 public function __construct($alias)
 {
     $this->_engine = Cache::engine($alias);
 }
开发者ID:kayamaox,项目名称:Github,代码行数:9,代码来源:CacheBridge.php


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