當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。