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


PHP Cache::config方法代码示例

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


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

示例1: testCacheSettings

 /**
  * キャッシュの初期設定をチェックする
  *
  * @param string $name 		キャッシュ名
  * @param string $prefix 	接頭語
  * @param string $path 		ディレクトリパス
  * @param string $duration	キャッシュ時間
  * @dataProvider getCacheSettingDataProvider
  */
 public function testCacheSettings($name, $prefix, $path, $duration)
 {
     $config = Cache::config($name);
     $this->assertEquals($prefix, $config['settings']['prefix']);
     $this->assertEquals($duration, $config['settings']['duration']);
     $this->assertTrue(strpos($config['settings']['path'], $path) === 0);
 }
开发者ID:baserproject,项目名称:basercms,代码行数:16,代码来源:BootstrapTest.php

示例2: testTranslationCaching

 /**
  * testTranslationCaching method
  *
  * @return void
  */
 public function testTranslationCaching()
 {
     Configure::write('Config.language', 'cache_test_po');
     // reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     $lang = Configure::read('Config.language');
     Cache::config('_cake_core_', Cache::config('default'));
     // 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:kuradakis,项目名称:cakephp-ex,代码行数:37,代码来源:I18nTest.php

示例3: configureCache

 /**
  * Configure a cache engine
  *
  * @param string $name Name of the Cache engine
  * @param array $settings Additional settings to merge into \defaultCacheSettings
  * @return void
  */
 public static function configureCache($name, $settings = array())
 {
     $settings = array_merge(array('duration' => static::getCacheTimeout(), 'prefix' => basename(dirname(dirname(APP)))), static::$defaultCacheSettings, Configure::read('RedisCache.cache'), $settings);
     $settings['prefix'] .= '.' . str_replace('_', '.', $name) . '.';
     $settings['prefix'] = str_replace('..', '.', $settings['prefix']);
     Cache::config($name, $settings);
 }
开发者ID:nodesagency,项目名称:RedisCache,代码行数:14,代码来源:RedisCache.php

示例4: setUp

/**
 * start a test
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		$this->_pluginPath = App::pluginPath('AssetCompress');
		$this->_testFiles = $this->_pluginPath . 'Test' . DS . 'test_files' . DS;
		$testFile = $this->_testFiles . 'Config' . DS . 'config.ini';

		AssetConfig::clearAllCachedKeys();

		Cache::drop(AssetConfig::CACHE_CONFIG);
		Cache::config(AssetConfig::CACHE_CONFIG, array(
			'path' => TMP,
			'prefix' => 'asset_compress_test_',
			'engine' => 'File'
		));

		$controller = null;
		$request = new CakeRequest(null, false);
		$request->webroot = '';
		$view = new View($controller);
		$view->request = $request;
		$this->Helper = new AssetCompressHelper($view, array('noconfig' => true));
		$Config = AssetConfig::buildFromIniFile($testFile);
		$this->Helper->config($Config);
		$this->Helper->Html = new HtmlHelper($view);

		Router::reload();
		Configure::write('debug', 2);
	}
开发者ID:renan,项目名称:asset_compress,代码行数:33,代码来源:AssetCompressHelperTest.php

示例5: __construct

 public function __construct()
 {
     parent::__construct();
     if (!Cache::config(self::CACHE_CONFIG)) {
         Cache::config(self::CACHE_CONFIG, array('engine' => 'File', 'duration' => 300, 'prefix' => 'attachable_', 'probability' => 100, 'serialize' => true, 'path' => MEDIA_CACHE_DIR));
     }
 }
开发者ID:fm-labs,项目名称:cakephp-media,代码行数:7,代码来源:AttachableBehaviorOld.php

示例6: testConfigChange

 function testConfigChange()
 {
     $result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions'));
     $this->assertEqual($result['settings'], Cache::settings('File'));
     $result = Cache::config('tests', array('engine' => 'File', 'path' => TMP . 'tests'));
     $this->assertEqual($result['settings'], Cache::settings('File'));
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:7,代码来源:cache.test.php

示例7: testDelete

 /**
  * testDelete function
  *
  * @return void
  * @access public
  */
 function testDelete()
 {
     // Without params
     $this->Shell->delete();
     $this->Shell->expectAt(0, 'out', array(new PatternExpectation('/Usage/')));
     // Invalid config
     $this->Shell->args = array('cache_test');
     $this->Shell->delete();
     $this->Shell->expectAt(0, 'err', array(new PatternExpectation('/not found/')));
     $this->Shell->expectCallCount('_stop', 2);
     Cache::config('cache_test', Cache::config('default'));
     // With config
     Cache::write('anything', array('a'), 'cache_test');
     Cache::write('anything2', array('b'), 'cache_test');
     $this->assertTrue(Cache::read('anything', 'cache_test') !== false);
     $this->Shell->args = array('cache_test');
     $this->Shell->delete();
     $this->assertFalse(Cache::read('anything', 'cache_test'));
     // With config
     Cache::write('anything', array('a'), 'cache_test');
     Cache::write('anything2', array('b'), 'cache_test');
     $this->assertTrue(Cache::read('anything', 'cache_test') !== false);
     $this->Shell->args = array('cache_test', 'anything');
     $this->Shell->delete();
     $this->assertFalse(Cache::read('anything', 'cache_test'));
     $this->assertTrue(Cache::read('anything2', 'cache_test') !== false);
 }
开发者ID:sams,项目名称:cache,代码行数:33,代码来源:cache_shell.test.php

示例8: startTest

 /**
  * startTest
  *
  * @return void
  */
 public function startTest()
 {
     $this->cache_path = CACHE . 'models' . DS;
     Cache::config('default', array('prefix' => 'cake_', 'engine' => 'File', 'path' => $this->cache_path, 'duration' => '+1 hour'));
     $this->Article = ClassRegistry::init('Article');
     $this->User = ClassRegistry::init('User');
 }
开发者ID:ndejong,项目名称:CakephpAutocacheBehavior,代码行数:12,代码来源:AutocacheBehaviorTest.php

示例9: find

 /**
  * Wrapper find to cache sql queries
  * @param array $conditions
  * @param array $fields
  * @param string $order
  * @param string $recursive
  * @return array
  */
 function find($conditions = null, $fields = array(), $order = null, $recursive = null)
 {
     if (Configure::read('Cache.disable') === false && Configure::read('Cache.check') === true && (isset($fields['cache']) && $fields['cache'] !== false || $this->tempCache != null)) {
         if ($this->tempCache != null && isset($fields['cache']) && $fields['cache'] !== false) {
             $fields['cache'] = $this->tempCache;
         }
         $this->tempCache = null;
         $key = $fields['cache'];
         $expires = '+1 hour';
         if (is_array($fields['cache'])) {
             $key = $fields['cache'][0];
             if (isset($fields['cache'][1])) {
                 $expires = $fields['cache'][1];
             }
         }
         // Set cache settings
         Cache::config('sql_cache', array('prefix' => strtolower($this->name) . '-', 'duration' => $expires));
         // Load from cache
         $results = Cache::read($key, 'sql_cache');
         if (!is_array($results)) {
             $results = parent::find($conditions, $fields, $order, $recursive);
             Cache::write($key, $results, 'sql_cache');
         }
         return $results;
     }
     // Not cacheing
     return parent::find($conditions, $fields, $order, $recursive);
 }
开发者ID:gersonjnr,项目名称:portabilis,代码行数:36,代码来源:app_model.php

示例10: startTest

 /**
  * startTest
  *
  * @return void
  */
 public function startTest($method)
 {
     $this->cache_path = CACHE;
     Cache::config('default', array('engine' => 'File', 'path' => $this->cache_path, 'duration' => '+10 seconds'));
     $this->Article = ClassRegistry::init('Article');
     $this->User = ClassRegistry::init('User');
 }
开发者ID:ndejong,项目名称:CakephpAutocachePlugin,代码行数:12,代码来源:AutocachePluginTest.php

示例11: __construct

 function __construct()
 {
     App::import('Xml');
     App::import('Core', 'HttpSocket');
     $this->HttpSocket = new HttpSocket();
     Cache::config('rss', array('engine' => 'File', 'duration' => '+12 hours', 'path' => CACHE . 'rss', 'prefix' => 'rss_'));
     parent::__construct();
 }
开发者ID:amerlini,项目名称:digigas-from-hg,代码行数:8,代码来源:rss_source.php

示例12: __construct

 public function __construct()
 {
     parent::__construct();
     $this->Estatistica = new Estatistica();
     $this->EstatisticaTransicao = new EstatisticaTransicao();
     ini_set('memory_limit', '1G');
     Cache::config('_cake_model_', array('engine' => 'File', 'prefix' => 'shell' . 'cake_model_', 'path' => CACHE . 'models' . DS, 'serialize' => true, 'duration' => '+999 days'));
 }
开发者ID:TerrasAppSolutions,项目名称:seeg-mapbiomas-workspace,代码行数:8,代码来源:StatsinputShell.php

示例13: tearDown

 public function tearDown()
 {
     Cache::delete('test' . 'Setting.cache');
     Cache::clear();
     @unlink(TMP . 'tests' . DS . 'cake_test_setting_cache');
     Configure::write('Cache.disable', $this->_cacheDisable);
     Cache::config('default', $this->_defaultCacheConfig['settings']);
 }
开发者ID:k1low,项目名称:setting,代码行数:8,代码来源:SystemControlTest.php

示例14: __construct

 /**
  * Get the models from Cake by their name
  */
 public function __construct()
 {
     $this->tagModel = ClassRegistry::init($this->tagName);
     $this->listModel = ClassRegistry::init($this->listName);
     if (Cache::config('tagcloud') === false) {
         Cache::config('tagcloud', array('engine' => 'File', 'serialize' => true, 'prefix' => ''));
     }
 }
开发者ID:ni-c,项目名称:photocake,代码行数:11,代码来源:TagCloudComponent.php

示例15: __construct

 /**
  * TinyAuthorize::__construct()
  *
  * @param ComponentCollection $Collection
  * @param array $config
  */
 public function __construct(ComponentCollection $Collection, $config = [])
 {
     $config += $this->_defaultConfig;
     parent::__construct($Collection, $config);
     if (Cache::config($config['cache']) === false) {
         throw new CakeException(sprintf('TinyAuth could not find `%s` cache - expects at least a `default` cache', $config['cache']));
     }
 }
开发者ID:ByMyHandsOnly,项目名称:BMHO_Web,代码行数:14,代码来源:TinyAuthorize.php


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