本文整理汇总了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);
}
示例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'));
}
示例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);
}
示例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);
}
示例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));
}
}
示例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'));
}
示例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);
}
示例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');
}
示例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);
}
示例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');
}
示例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();
}
示例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'));
}
示例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']);
}
示例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' => ''));
}
}
示例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']));
}
}