Exemple #1
0
<?php

define('APP_NAME', 'test');
chdir(getcwd() . '/../');
$conf = (include './conf/conf.php');
$conf['cache']['type'] = 'memcached';
include './xiunophp/xiunophp.php';
$r = cache_get('test2');
x('cache_get test2:', $r, NULL);
$r = cache_set('test', array('123'));
x('cache_set', $r, true);
$r = cache_get('test');
x('cache_get', $r[0], '123');
$r = cache_delete('test');
x('cache_delete', $r, TRUE);
$r = cache_get('test');
x('cache_get', $r, NULL);
$r = cache_truncate();
x('cache_truncate', $r, TRUE);
function x($info, $a, $b)
{
    echo "{$info}: ... " . ($a === $b ? '[ok]' : var_export($a, 1) . ", except:" . var_export($b, 1)) . "\r\n";
}
<?php

!defined('DEBUG') and exit('Access Denied.');
$action = param(1);
if ($action == 'clear') {
    if ($method == 'GET') {
        $header['title'] = '清理缓存';
        include "./admin/view/cache_clear.htm";
    } elseif ($method == 'POST') {
        $old = $runtime;
        $clearcache = param('clearcache', 0);
        $clearcache and $r = cache_truncate();
        // 清空缓存会导致今日发帖丢失
        runtime_init();
        runtime_set('todayposts', $old['todayposts']);
        runtime_set('todayusers', $old['todayusers']);
        runtime_set('todaythreads', $old['todaythreads']);
        $rebuildmaxid = param('rebuildmaxid', 0);
        if ($rebuildmaxid) {
            @ignore_user_abort(TRUE);
            @set_time_limit(0);
            table_day_rebuild();
        }
        thread_new_sitemap();
        message(0, '清理成功');
    }
} elseif ($action == 'maxid') {
}