本文整理汇总了PHP中Cache::configured方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::configured方法的具体用法?PHP Cache::configured怎么用?PHP Cache::configured使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::configured方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cache
/**
* Display all cache configurations.
*/
public function cache()
{
$config = array();
foreach (Cache::configured() as $key) {
$temp = Cache::config($key);
$config[$key] = $temp['settings'];
}
ksort($config);
$this->set('configuration', $config);
}
示例2: engines
/**
* Clears content of cache engines
*
* @param mixed any amount of strings - keys of configure cache engines
* @return array associative array with cleanup results
* @access public
*/
function engines()
{
$result = array();
$keys = Cache::configured();
if ($engines = func_get_args()) {
$keys = array_intersect($keys, $engines);
}
foreach ($keys as $key) {
$result[$key] = Cache::clear(false, $key);
}
return $result;
}
示例3: _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);
}
}
示例4: execute
/**
* Run the task
*
* @return void
*/
public function execute()
{
// @todo Implement cache "type" clearing, so you can clear just models, and leave cached views untouched.
// $type = 'all';
// if (!empty($this->args)) {
// $type = $this->args[0];
// }
foreach (Cache::configured() as $name) {
$config = Cache::config($name);
if (Cache::clear(false, $name)) {
$this->out('- Cleared ' . $name);
} else {
$this->out('! Failed clearing ' . $name);
}
}
}
示例5: __construct
/**
* Constructor
*
* @param array $settings Array of settings.
* @return void
*/
public function __construct($settings)
{
parent::__construct();
$this->title = __d('clear_cache', 'Clear Cache');
foreach (glob(CACHE . '*', GLOB_ONLYDIR) as $folder) {
$length = strrpos($folder, DS) + 1;
$this->folders[] = substr($folder, $length);
}
$configured = array_diff(Cache::configured(), array('debug_kit'));
$this->engines = array_merge($this->engines, $configured);
foreach (array('folders', 'engines') as $property) {
if (isset($settings['clear_cache'][$property])) {
$this->{$property} = (array) $settings['clear_cache'][$property];
}
}
}
示例6: delete
public function delete()
{
$this->autoRender = false;
if ($this->params['[method]'] !== 'DELETE') {
$this->cakeError('error404');
}
$configured = Cache::configured();
if (!in_array($this->params['config'], $configured)) {
$this->cakeError('error404');
}
if (empty($this->params['key'])) {
Cache::clear(false, $this->params['config']);
} else {
Cache::delete($this->params['key'], $this->params['config']);
}
}
示例7: _clearCache
/**
* Clear cache
*/
protected function _clearCache()
{
if ($this->args[0] === 'all') {
$cacheNames = Cache::configured();
} else {
$cacheNames = array_map('trim', explode(',', $this->args[0]));
}
foreach ($cacheNames as $cacheName) {
$success = Cache::clear(false, $cacheName);
if ($success) {
$this->out("Cache: {$cacheName} cleared");
} else {
$this->err("Cache: {$cacheName} NOT cleared!");
}
}
}
示例8: delete
/**
* Delete cache
*
* @return void
* @access protected
*/
function delete()
{
if (empty($this->args) || count($this->args) > 2) {
$this->help();
return $this->_stop();
}
$configured = Cache::configured();
if (!in_array($this->args[0], $configured)) {
$this->err(sprintf(__d('cache', 'Configuration "%s" not found.', true), $this->args[0]));
return $this->_stop();
}
if (isset($this->args[1])) {
Cache::delete($this->args[1], $this->args[0]);
} else {
Cache::clear(false, $this->args[0]);
}
}
示例9: engines
/**
* Clears content of cache engines
*
* @param mixed any amount of strings - keys of configure cache engines
* @return array associative array with cleanup results
*/
public function engines()
{
if ($cacheDisabled = (bool) Configure::read('Cache.disable')) {
Configure::write('Cache.disable', false);
}
$result = array();
$keys = Cache::configured();
if ($engines = func_get_args()) {
$keys = array_intersect($keys, $engines);
}
foreach ($keys as $key) {
$result[$key] = Cache::clear(false, $key);
}
if ($cacheDisabled) {
Configure::write('Cache.disable', $cacheDisabled);
}
return $result;
}
示例10: testClear
/**
* Test cache clear task
*
* @param string $cacheNames
*
* @dataProvider clearProvider
*/
public function testClear($cacheNames)
{
$cacheKey = 'CacheShellTest';
$caches = array_map('trim', explode(',', $cacheNames));
if ($caches[0] === 'all') {
$caches = Cache::configured();
}
foreach ($caches as $cache) {
Cache::write($cacheKey, true, $cache);
$this->assertTrue(Cache::read($cacheKey, $cache));
}
$this->Shell->startup();
$this->Shell->initialize();
$this->Shell->runCommand('clear', array('clear', $cacheNames));
foreach ($caches as $cache) {
$this->assertFalse(Cache::read($cacheKey, $cache));
}
debug($this->out);
}
示例11: clear
/**
* Clear cache task
*/
public function clear()
{
$force = empty($this->params['force']) ? false : true;
$clearSession = empty($this->params['clear-session']) ? false : true;
$configs = Cache::configured();
foreach ($configs as $config) {
if ('_cache_session_' == $config && !$clearSession) {
continue;
}
if ($force) {
Cache::clear(false, $config);
} else {
$prompt = __d('cake_console', 'Are you want clear cache of config %s ?', $config);
if ('y' == $this->in($prompt, array('y', 'n'), 'y')) {
$cleared = Cache::clear(false, $config);
if ($cleared) {
$this->out(__d('cake_console', 'Cleared success cache of config %s', $config));
} else {
$this->out(__d('cake_console', 'Cleared failture cache of config %s', $config));
}
}
}
}
}
示例12: delete
/**
* Removes record for given ID. If no ID is given, the current ID is used. Returns true on success.
*
* @param int|string $id ID of record to delete
* @param bool $cascade Set to true to delete records that depend on this record
* @return bool True on success
* @triggers Model.beforeDelete $this, array($cascade)
* @triggers Model.afterDelete $this
* @link http://book.cakephp.org/2.0/en/models/deleting-data.html
*/
public function delete($id = null, $cascade = true)
{
/**
* Returns an array containing the currently configured Cache settings.
*
* @return array Array of configured Cache config names.
*/
$cacheConfigNames = Cache::configured();
foreach ($cacheConfigNames as $name) {
/**
* Delete all keys from the cache.
*
* @param boolean $check if true will check expiration, otherwise delete all
* @param string $config name of the configuration to use. Defaults to 'default'
* @return boolean True if the cache was successfully cleared, false otherwise
*/
if (Cache::clear(false, $name)) {
continue;
} else {
return false;
}
}
return true;
}
示例13: testConfigured
/**
* test that configured returns an array of the currently configured cache
* settings
*
* @return void
*/
public function testConfigured()
{
$result = Cache::configured();
$this->assertTrue(in_array('_cake_core_', $result));
$this->assertTrue(in_array('default', $result));
}
示例14: _clearCache
/**
* Clear all caches present related to models
*
* Before the 'after' callback method be called is needed to clear all caches.
* Without it any model operations will use cached data instead of real/modified
* data.
*
* @return void
*/
protected function _clearCache()
{
// Clear the cache
DboSource::$methodCache = array();
$keys = Cache::configured();
foreach ($keys as $key) {
Cache::clear(false, $key);
}
ClassRegistry::flush();
// Refresh the model, in case something changed
if ($this->Version instanceof MigrationVersion) {
$this->Version->initVersion();
}
}
示例15: cache
/**
* Get/Set caching.
*
* @param null|boolean|string $cache Cache config name to use, If true is passed, 'cake_pdf' will be used.
* @return mixed
*/
public function cache($cache = null)
{
if ($cache === null) {
return $this->_cache;
}
if ($cache === false) {
$this->_cache = false;
return $this;
}
if ($cache === true) {
$cache = 'cake_pdf';
}
if (!in_array($cache, Cache::configured())) {
throw new CakeException(sprintf('CakePdf cache is not configured: %s', $cache));
}
$this->_cache = $cache;
return $this;
}