本文整理汇总了PHP中Cache::settings方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::settings方法的具体用法?PHP Cache::settings怎么用?PHP Cache::settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::settings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeDBLog
private function writeDBLog($method, $requestData, $responseType, $_response = '', $proxy_used = '', $curlStatus = '')
{
$this->loadModel('LogAutoxp')->clear();
$ip = $_SERVER['REMOTE_ADDR'];
$proxy_type = $this->isBot($ip) ? 'Bot' : 'Site';
$this->loadModel('LogAutoxp')->save(array('ip_type' => $proxy_type, 'ip' => $ip, 'host' => gethostbyaddr($ip), 'ip_details' => json_encode($_SERVER), 'proxy_used' => $proxy_used, 'method' => $method, 'request' => $this->getRequestURL($requestData, $method), 'response_type' => $responseType, 'response_status' => $curlStatus ? json_encode($curlStatus) : '', 'response' => $_response, 'cache_id' => $responseType == 'CACHE' ? Hash::get(Cache::settings('autoxp'), 'data.id') : 0, 'cache' => $responseType == 'CACHE' ? Hash::get(Cache::settings('autoxp'), 'data.value') : ''));
}
示例2: testInitSettings
function testInitSettings()
{
Cache::engine('File', array('path' => TMP . 'tests'));
$settings = Cache::settings();
$expecting = array('duration' => 3600, 'probability' => 100, 'path' => TMP . 'tests', 'prefix' => 'cake_', 'lock' => false, 'serialize' => true);
$this->assertEqual($settings, $expecting);
}
示例3: testSettings
/**
* testSettings method
*
* @return void
*/
public function testSettings()
{
$settings = Cache::settings('memcached');
unset($settings['path']);
$expecting = array('prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, 'servers' => array('127.0.0.1'), 'persistent' => false, 'compress' => false, 'engine' => 'Memcached', 'login' => null, 'password' => null, 'groups' => array(), 'serialize' => 'php', 'options' => array());
$this->assertEquals($expecting, $settings);
}
示例4: testCacheDirChange
/**
* testCacheDirChange method
*
* @return void
*/
public function testCacheDirChange()
{
$result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions'));
$this->assertEquals($result['settings'], Cache::settings('sessions'));
$result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertEquals($result['settings'], Cache::settings('sessions'));
$this->assertNotEquals($result['settings'], Cache::settings('default'));
}
示例5: testSettings
/**
* testSettings method
*
* @return void
*/
public function testSettings()
{
$settings = Cache::settings();
$expecting = array('prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, 'engine' => 'Xcache');
$this->assertTrue(isset($settings['PHP_AUTH_USER']));
$this->assertTrue(isset($settings['PHP_AUTH_PW']));
unset($settings['PHP_AUTH_USER'], $settings['PHP_AUTH_PW']);
$this->assertEquals($settings, $expecting);
}
示例6: _setupCache
/**
* _setupCache
* Differentiate croogo's cache prefix so that sites have their own cache
* List of cache names are from croogo_bootstrap.php
*/
public function _setupCache(Controller $controller)
{
$configured = Cache::configured();
$croogoCacheNames = array('croogo_blocks', 'croogo_menus', 'croogo_nodes', 'croogo_types', 'croogo_vocabularies', 'croogo_vocabularies', 'nodes_promoted', 'nodes_term', 'nodes_index', 'contacts_view');
$siteTitle = Inflector::slug(strtolower(Configure::read('Site.title')));
for ($i = 0, $ii = count($configured); $i < $ii; $i++) {
if (!in_array($configured[$i], $croogoCacheNames)) {
continue;
}
$cacheName = $configured[$i];
$setting = Cache::settings($cacheName);
$setting = Set::merge($setting, array('prefix' => 'cake_' . $siteTitle . '_'));
Cache::config($cacheName, $setting);
}
}
示例7: wf_jlm
/**
* Output parsed JLM javascript file
*
* The output is cached when not in debug mode.
*/
function wf_jlm()
{
$javascripts = Cache::read('wf_jlm');
if (empty($javascripts) or Configure::read('debug') > 0) {
$javascripts = $this->JlmPackager->concate();
Cache::write('wf_jlm', $javascripts);
}
$this->layout = false;
$this->set(compact('javascripts'));
$this->RequestHandler->respondAs('application/javascript');
$cacheSettings = Cache::settings();
$file = CACHE . $cacheSettings['prefix'] . 'wf_jlm';
$this->JlmPackager->browserCacheHeaders(filemtime($file));
Configure::write('debug', 0);
}
示例8: testConnect
/**
* testConnect method
*
* @return void
*/
public function testConnect()
{
$Memcache = new MemcacheEngine();
$Memcache->init(Cache::settings('memcache'));
$result = $Memcache->connect('127.0.0.1');
$this->assertTrue($result);
}
示例9: testSettings
/**
* testSettings method
*
* @access public
* @return void
*/
function testSettings()
{
$settings = Cache::settings();
$expecting = array('prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, 'servers' => array('127.0.0.1'), 'compress' => false, 'engine' => 'Memcache');
$this->assertEqual($settings, $expecting);
}
示例10: testSettings
/**
* testSettings method
*
* @access public
* @return void
*/
function testSettings()
{
$settings = Cache::settings();
$expecting = array('prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, 'engine' => 'Xcache', 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password');
$this->assertEqual($settings, $expecting);
}
示例11: testSet
/**
* testSet method
*
* @access public
* @return void
*/
function testSet()
{
$_cacheSet = Cache::set();
Cache::set(array('duration' => '+1 year'));
$data = Cache::read('test_cache');
$this->assertFalse($data);
$data = 'this is just a simple test of the cache system';
$write = Cache::write('test_cache', $data);
$this->assertTrue($write);
Cache::set(array('duration' => '+1 year'));
$data = Cache::read('test_cache');
$this->assertEqual($data, 'this is just a simple test of the cache system');
Cache::delete('test_cache');
$global = Cache::settings();
Cache::set($_cacheSet);
}
示例12: updateBayesianAverage
/**
* Updates the Bayesian average(s) for affected items.
*
* @param object $Model Ratings model this applies to
* @param number $itemId ID of item whose ratings are being saved. Updates everything if this is false.
* @access public
*/
function updateBayesianAverage(&$Model, $itemId = false)
{
extract($this->__settings[$Model->alias]);
$ItemModel =& $this->getItemModel($Model);
$updateConditions = array($ItemModel->alias . '.' . $fields['ratingsCount'] . ' >' => '0');
$updateSingle = $itemId ? true : false;
# whether to update Bayesian avg just for this itemId or all items
// Get constant/mean average from cache or db if either is inexplicit
if (!$C || !$m) {
$cache['data'] = Cache::read($cache['prefix'] . $Model->alias, $cache['config']);
if (!$cache['calculationDuration']) {
$cacheSettings = Cache::settings();
$cache['calculationDuration'] = $cacheSettings['duration'] / 2;
}
if (!$cache['data'] || time() - $cache['data']['time'] > $cache['calculationDuration']) {
// Calculate latest Constant and mean from the database
$allStats = $ItemModel->find('first', array('fields' => array("AVG({$ItemModel->alias}.{$fields['ratingsCount']}) C", "AVG({$ItemModel->alias}.{$fields['meanRating']}) m"), 'conditions' => array("{$ItemModel->alias}.{$fields['ratingsCount']} >" => '0'), 'recursive' => -1));
if (!$C) {
// If cache value isn't set or the difference between it and the current value is greater than 10%, update the cache and all items
if (!isset($cache['data']['C']) || abs($allStats[0]['C'] - $cache['data']['C']) > $cache['data']['C'] * 0.1) {
$C = $allStats[0]['C'];
$updateSingle = false;
} else {
$C = $cache['data']['C'];
}
}
if (!$m) {
// If cache value isn't set or the difference between it and the current value is greater than 10%, update the cache and all items
if (!isset($cache['data']['m']) || abs($allStats[0]['m'] - $cache['data']['m']) > $cache['data']['m'] * 0.1) {
$m = $allStats[0]['m'];
$updateSingle = false;
} else {
$m = $cache['data']['m'];
}
}
// Update the cache
Cache::write($cache['prefix'] . $Model->alias, array('time' => time(), 'C' => $C, 'm' => $m), $cache['config']);
} else {
$C = $cache['data']['C'];
$m = $cache['data']['m'];
}
}
// Only update the data for one item
if ($updateSingle) {
if ($useForeignKey) {
$updateConditions["{$ItemModel->alias}.{$fields['itemId']}"] = $itemId;
} else {
$updateConditions["{$ItemModel->alias}.{$ItemModel->primaryKey}"] = $itemId;
}
}
// Update the affected items' bayesian averages
if ($C > 2) {
$n = $ItemModel->escapeField($fields['ratingsCount']);
$j = $ItemModel->escapeField($fields['meanRating']);
$formula = "({$n} / ({$n} + {$C})) * {$j} + ({$C} / ({$n} + {$C})) * {$m}";
} else {
$formula = $ItemModel->escapeField($fields['meanRating']);
}
$ItemModel->updateAll(array($ItemModel->alias . '.' . $fields['bayesianRating'] => $formula), $updateConditions);
}
示例13: testClearCached
/**
* Test deleting specific cache data
*
* @since 0.1
* @author Joshua McNeese <jmcneese@gmail.com>
* @return void
*/
public function testClearCached()
{
$uuid1 = String::uuid();
$key1 = 'test';
$data1 = array('foo', 'bar', 'baz');
$this->CacheThing->setCached($key1, $data1);
$this->CacheThing->setCached($key1, $data1, $uuid1);
$result1 = $this->CacheThing->clearCached(false);
$this->assertTrue($result1);
$config1 = Cache::settings($this->CacheThing->getCacheConfig());
$folder1 = new Folder($config1['path']);
$contents1 = $folder1->read();
$this->assertTrue(count($contents1['1']) == 0);
$result2 = $this->CacheThing->clearCached(false, $uuid1);
$this->assertTrue($result2);
$config2 = Cache::settings($this->CacheThing->getCacheConfig($uuid1));
$folder2 = new Folder($config2['path']);
$contents2 = $folder2->read();
$this->assertTrue(count($contents2['1']) == 0);
}
示例14: getPrefixCacheKey
function getPrefixCacheKey($key, $config = 'default')
{
$settings = Cache::settings($config);
if (empty($settings) || !self::isInitialized($config)) {
return '';
}
$key = MemcacheEngine::key($key);
if (!$key) {
return '';
}
return $settings['prefix'] . $key;
}
示例15: __loadBootstrap
/**
* Loads the app/config/bootstrap.php
* If the alternative paths are set in this file
* they will be added to the paths vars
*
* @param boolean $boot Load application bootstrap (if true)
* @access private
*/
function __loadBootstrap($boot)
{
$_this =& Configure::getInstance(false);
$modelPaths = $behaviorPaths = $controllerPaths = $componentPaths = $viewPaths = $helperPaths = $pluginPaths = $vendorPaths = null;
if ($boot) {
$_this->write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR));
if (php_sapi_name() == 'isapi') {
$_this->write('App.server', 'IIS');
}
if (!(include APP_PATH . 'config' . DS . 'core.php')) {
trigger_error(sprintf(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", true), CONFIGS), E_USER_ERROR);
}
if (!(include APP_PATH . 'config' . DS . 'bootstrap.php')) {
trigger_error(sprintf(__("Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", true), CONFIGS), E_USER_ERROR);
}
if ($_this->read('Cache.disable') !== true) {
$cache = Cache::settings();
if (empty($cache)) {
trigger_error('Cache not configured properly. Please check Cache::config(); in APP/config/core.php', E_USER_WARNING);
list($engine, $cache) = Cache::config('default', array('engine' => 'File'));
}
if (Configure::read() > 1) {
$cache['duration'] = 10;
}
$settings = array('prefix' => 'cake_core_', 'path' => CACHE . 'persistent' . DS, 'serialize' => true);
$config = Cache::config('_cake_core_', array_merge($cache, $settings));
}
}
$_this->__buildPaths(compact('modelPaths', 'viewPaths', 'controllerPaths', 'helperPaths', 'componentPaths', 'behaviorPaths', 'pluginPaths'));
if (defined('BASE_URL')) {
trigger_error('BASE_URL Deprecated: See Configure::write(\'App.baseUrl\', \'' . BASE_URL . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('App.baseUrl', BASE_URL);
}
if (defined('DEBUG')) {
trigger_error('DEBUG Deprecated: Use Configure::write(\'debug\', ' . DEBUG . '); in APP/config/core.php', E_USER_WARNING);
$_this->write('debug', DEBUG);
}
if (defined('CAKE_ADMIN')) {
trigger_error('CAKE_ADMIN Deprecated: Use Configure::write(\'Routing.admin\', \'' . CAKE_ADMIN . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Routing.admin', CAKE_ADMIN);
}
if (defined('WEBSERVICES')) {
trigger_error('WEBSERVICES Deprecated: Use Router::parseExtensions(); or add Configure::write(\'Routing.webservices\', \'' . WEBSERVICES . '\');', E_USER_WARNING);
$_this->write('Routing.webservices', WEBSERVICES);
}
if (defined('ACL_CLASSNAME')) {
trigger_error('ACL_CLASSNAME Deprecated. Use Configure::write(\'Acl.classname\', \'' . ACL_CLASSNAME . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Acl.classname', ACL_CLASSNAME);
}
if (defined('ACL_DATABASE')) {
trigger_error('ACL_DATABASE Deprecated. Use Configure::write(\'Acl.database\', \'' . ACL_CLASSNAME . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Acl.database', ACL_CLASSNAME);
}
if (defined('CAKE_SESSION_SAVE')) {
trigger_error('CAKE_SESSION_SAVE Deprecated. Use Configure::write(\'Session.save\', \'' . CAKE_SESSION_SAVE . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Session.save', CAKE_SESSION_SAVE);
}
if (defined('CAKE_SESSION_TABLE')) {
trigger_error('CAKE_SESSION_TABLE Deprecated. Use Configure::write(\'Session.table\', \'' . CAKE_SESSION_TABLE . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Session.table', CAKE_SESSION_TABLE);
}
if (defined('CAKE_SESSION_STRING')) {
trigger_error('CAKE_SESSION_STRING Deprecated. Use Configure::write(\'Security.salt\', \'' . CAKE_SESSION_STRING . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Security.salt', CAKE_SESSION_STRING);
}
if (defined('CAKE_SESSION_COOKIE')) {
trigger_error('CAKE_SESSION_COOKIE Deprecated. Use Configure::write(\'Session.cookie\', \'' . CAKE_SESSION_COOKIE . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Session.cookie', CAKE_SESSION_COOKIE);
}
if (defined('CAKE_SECURITY')) {
trigger_error('CAKE_SECURITY Deprecated. Use Configure::write(\'Security.level\', \'' . CAKE_SECURITY . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Security.level', CAKE_SECURITY);
}
if (defined('CAKE_SESSION_TIMEOUT')) {
trigger_error('CAKE_SESSION_TIMEOUT Deprecated. Use Configure::write(\'Session.timeout\', \'' . CAKE_SESSION_TIMEOUT . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Session.timeout', CAKE_SESSION_TIMEOUT);
}
if (defined('AUTO_SESSION')) {
trigger_error('AUTO_SESSION Deprecated. Use Configure::write(\'Session.start\', \'' . AUTO_SESSION . '\'); in APP/config/core.php', E_USER_WARNING);
$_this->write('Session.start', (bool) AUTO_SESSION);
}
}