xoops forums

wishcraft

Module Developer
Posted on: 2009/8/10 18:01
wishcraft
wishcraft (Show more)
Module Developer
Posts: 3711
Since: 2007/5/18
#1

Drop the cache - Quickly

Here is a bit of code you can put in an HTML page to drop the cache quickly, very simple. Your Code View::
<?php
    
echo '<ul><li>ok</li>';
    
error_reporting(E_ALL);
    echo 
'<li>Error Checking on - ok<li>';    
    
define('XOOPS_VAR_PATH''/home/../../xoops_data');
    echo 
'<li>Path Set - '.XOOPS_VAR_PATH.'</li>';    
    
$start[0] = time();
    
$length[0] = 60*4;
    
set_time_limit($length[0]);
    echo 
'<li>Step Smarty Cache Clear Started</li>';
    
unlinkRecursive(XOOPS_VAR_PATH.'/caches/smarty_cache'false);
    echo 
'<li>Step Smarty Cache Clear Ended</li>';
    
$start[1] = time();
    
$length[1] += $start[1] - $length[0];
    
set_time_limit($length[1]);
    echo 
'<li>Step Smarty Compile Clear Started</li>';
    
unlinkRecursive(XOOPS_VAR_PATH.'/caches/smarty_compile'false);
    echo 
'<li>Step Smarty Compile Clear Ended</li>';
    
$start[2] = time();
    
$length[2] += $start[2] - $length[1];
    
set_time_limit($length[2]);
    echo 
'<li>Step XOOPS Cache Started</li>';
    
unlinkRecursive(XOOPS_VAR_PATH.'/caches/xoops_cache'false);
    
$end time();
    echo 
'<li>Step XOOPS Cache Ended</li></ul>';

    exit(
0);

/**
 * Recursively delete a directory
 *
 * @param string $dir Directory name
 * @param boolean $deleteRootToo Delete specified top-level directory as well
 */
function unlinkRecursive($dir$deleteRootToo)
{
    if(!
$dh = @opendir($dir))
    {
        return;
    }
    while (
false !== ($obj readdir($dh)))
    {
        if(
$obj == '.' || $obj == '..')
        {
            continue;
        }

        if (!@
unlink($dir '/' $obj))
        {
            
unlinkRecursive($dir.'/'.$objtrue);
        }
    }

    
closedir($dh);
   
    if (
$deleteRootToo)
    {
        @
rmdir($dir);
    }
   
    return;
}
?>

DonCurioso

Quite a regular
Posted on: 2009/8/10 19:09
DonCurioso
DonCurioso (Show more)
Quite a regular
Posts: 239
Since: 2009/3/1 1
#2

Re: Drop the cache - Quickly

Hi Wishcraft,

you can find this hack to have a direct link into administration, called xDelCache.

Basically, do the same.

Regards

wishcraft

Module Developer
Posted on: 2009/8/11 12:29
wishcraft
wishcraft (Show more)
Module Developer
Posts: 3711
Since: 2007/5/18
#3

Re: Drop the cache - Quickly

To Don,

How are you? You will notice in most cache cleaning in XOOPS as smarty is always instantiated on XOOPS I have not found any form of clear step to completely clearing a cache including shadow files, for example other internets that use your computer like .int, .mil, .sse and so on all have a 'different' internet, so when you are sitting on this one you only see the files we use.

To clear the cache completely that is the best method, as if you have XOOPS attached it will only clear top layer files.

Thanks

Simon