Exemple #1
0
<?php

namespace Lib;

use Memcache;
use Predis;
define('CACHE_LONG', 3600);
define('CACHE_MEDIUM', 600);
define('CACHE_SHORT', 60);
if (!defined('DISABLE_CACHE')) {
    define('DISABLE_CACHE', false);
}
if (!DISABLE_CACHE) {
    Cache::Connect();
}
// memcache class
class Cache
{
    private static $_memcache;
    private static $_redis;
    private static $_disabled = false;
    public static function Connect($host = 'localhost', $port = 11211)
    {
        self::$_memcache = new Memcache();
        if (!self::$_memcache->pconnect($host, $port)) {
            self::$_memcache = null;
        }
        self::setDisabled(isset($_GET['flushCache']));
    }
    public static function Set($key, $val, $expiration = 600)
    {