<?phpclass redisconnect{/** * Redis IP * * @var String */Const REDISHOSTNAME = "127.0.0.1"; /** * Redis's Port * * @var int */CONST REDISPORT = 6379; /** * Redis Time-out * * @var int */CONST REDISTIMEOUT = 0; /** * Redis's password * * @var unknown_type */Const REDISPASSWORD = "Ehualu"; /** * Redis's dbname * * @var int */CONST REDISDBNAME = 12; /** * Class * * @var Object */private static $instance; /** * REDIS Connection Handle * * @var Object */Private $redis; /** * Privatisation constructor to prevent out-of-class instantiation * * @param unknown_type $dbnumber */Private Function __construct () { Link database $this->redis = new Redis (); $this->redis->connect (Self::redishostname, Self::redisport, self::redistimeout); $this->redis->auth (Self::redispassword); $this->redis->select (self::redIsdbname); }/** * Privatize clone function to prevent an out-of-Class clone object */Private Function __clone () {}/** * The only public static method of class, gets the unique entry for the class singleton * * @return Object */public static function Getredisinstance () {if (! (Self:: $instance instanceof Self)) {self:: $instance = new self (); } return Self:: $instance; /** * Get a connection instance of Redis * * @return Redis */Public Function Getredisconn () {return $th is->redis; /** * needs to be cleaned during a single switch */Public function __destruct () {self:: $instance->redis->close (); Self:: $instance = NULL; }}?>
PHP Connect Redis Database Simple Interest class