PHP Connect Redis Database Simple Interest class

Source: Internet
Author: User

<?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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.