Example #1
0
function &cache_server()
{
    import('cache.lib');
    static $CS = null;
    if ($CS === null) {
        switch (CACHE_SERVER) {
            case 'memcached':
                $CS = new MemcacheServer(array('host' => MEMCACHE_HOST, 'port' => MEMCACHE_PORT));
                break;
            default:
                $CS = new PhpCacheServer();
                $CS->set_cache_dir(ROOT_PATH . '/temp/caches');
                break;
        }
    }
    return $CS;
}
Example #2
0
function &cache_server()
{
    import('cache.lib');
    static $CS = null;
    if ($CS === null) {
        switch (CACHE_SERVER) {
            case 'memcached':
                list($host, $port) = explode(':', CACHE_MEMCACHED);
                $CS = new MemcacheServer(array('host' => $host, 'port' => $port));
                break;
            default:
                $CS = new PhpCacheServer();
                $CS->set_cache_dir(ROOT_PATH . '/temp/caches');
                break;
        }
    }
    return $CS;
}
function &cache_server()
{
    import('cache.lib');
    static $CS = null;
    if ($CS === null) {
        switch (CACHE_SERVER) {
            case 'memcached':
                $CS = new MemcacheServer(array('host' => MEMCACHE_HOST, 'port' => MEMCACHE_PORT));
                break;
            default:
                $CS = new PhpCacheServer();
                //TODO:根据语言,使用不同的cachedir
                $temp_dir = ROOT_PATH . '/temp/caches/' . trim(LANG);
                $CS->set_cache_dir($temp_dir);
                if (!is_dir($temp_dir)) {
                    ecm_mkdir($temp_dir);
                }
                break;
        }
    }
    return $CS;
}
function &cache_server($cachetype = false)
{
    include PATH_APPLICATION . '/pm_cache.class.php';
    static $CS = null;
    if ($CS === null) {
        switch ($cachetype) {
            case '1':
                $CS = new MemcacheServer(array('host' => MEMCACHE_HOST, 'port' => MEMCACHE_PORT));
                break;
            case '3':
                $CS = new RedisServer(array('host' => REDIS_HOST, 'port' => REDIS_PORT));
                break;
            default:
                $CS = new PhpCacheServer();
                $CS->set_cache_dir(PATH_DATA . '/cache');
                break;
        }
    }
    return $CS;
}