<?php /* * Redis Cache */ class cache { private $redis = null;//only this class private $mysql = null; public function __construct($host, $port, $username, $password, $database) { if (!class_exists('Redis')) return false; try { $this->redis = new Redis(); $this->redis->connect($host, $port, '0.2');//timeout 200ms $this->redis->auth("{$username}-{$password}-{$database}"); } catch (RedisException $error) { return false; //var_dump($error); } } public function get($key) { return $this->redis->get($key); } public function set($key, $value, $express=0) { if ($express) return $this->redis->setex($key, $express, $value); else return $this->redis->set($key, $value); } public function delete($key) { return $this->redis->delete($key); } }