mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merging fixes and enhancements into trunk.
Revision: [2275] Change the way the cacheAction arrays can be set. var $cacheAction = array('action/params/' => time); Multiple params are allowed, will only cache params level and deeper (action/params/params/) var $cacheAction = array('action/' => time); Setting to just the method without any params will cache all request to that method. var $cacheAction = string; Will set cache time for entire class. Both settings can be used in the Controller::method(). $this->cacheAction = array() or string; Revision: [2274] Changed clearCache function to allow using url like param setting for cache. Example: One of the following can be used. clearCache('controller'); Will remove all cached pages that have the controller name. clearCache('controller/action/'); Will remove all cached pages that have the controller_action name. clearCache('controller/action/params'); Will remove all cached pages that have the controller_action_params name. Note you can have multiple params clearCache(array('controller/action/params','controller2/action/params)); You can also use and array to set more than one value, same setting as above apply to arrays. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2276 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2572317443
commit
de46dc7fdc
3 changed files with 12 additions and 3 deletions
|
@ -6,4 +6,4 @@
|
|||
// +---------------------------------------------------------------------------------------------------+ //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1.0.0.2273
|
||||
1.0.0.2276
|
|
@ -913,6 +913,7 @@ function clearCache($params = null, $type = 'views', $ext = '.php')
|
|||
{
|
||||
if(is_string($params) || $params === null)
|
||||
{
|
||||
$params = preg_replace('/\/\//', '/', $params);
|
||||
$cache = CACHE.$type.DS.$params;
|
||||
if(is_file($cache.$ext))
|
||||
{
|
||||
|
@ -958,6 +959,7 @@ function clearCache($params = null, $type = 'views', $ext = '.php')
|
|||
{
|
||||
foreach ($params as $key => $file)
|
||||
{
|
||||
$file = preg_replace('/\/\//', '/', $file);
|
||||
$cache = CACHE.$type.DS.'*'.$file.'*'.$ext;
|
||||
$files[] = glob($cache);
|
||||
}
|
||||
|
|
|
@ -663,9 +663,16 @@ class View extends Object
|
|||
{
|
||||
if(is_array($this->controller->cacheAction))
|
||||
{
|
||||
if(isset($this->controller->cacheAction[$this->action]))
|
||||
$check = str_replace('/', '_', $this->params['url']['url']);
|
||||
$check = str_replace('_'.$this->params['controller'].'_', '', $check);
|
||||
$check = substr_replace($check, '', -1);
|
||||
$keys = str_replace('/', '_', array_keys($this->controller->cacheAction));
|
||||
$key = preg_grep("/^$check/", array_values($keys));
|
||||
$key = str_replace('_', '/', $key['0']);
|
||||
|
||||
if(isset($this->controller->cacheAction[$key]))
|
||||
{
|
||||
$cacheTime = $this->controller->cacheAction[$this->action];
|
||||
$cacheTime = $this->controller->cacheAction[$key];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue