phpredis封装

<?php
/**
 * This is a Redis exntend class
 */

class RedisClient
{
    private static $instance = NULL;


    /**
     * Get a instance of MyRedisClient
     *
     * @param string $key
     * @return object
     */
    public  static function getInstance()
    {
        if (!self::$instance) {
            $redis = new \Redis();
            $redis->connect('127.0.0.1', 6379);
            $redis->auth('23');
            self::$instance = $redis;
        }
        return self::$instance;
    }




}




   $redis = \RedisClient::getInstance();
        $redis->incr('moban_fangwen');
        print_r($redis->get('moban_fangwen'));
        exit();
?>

原创文章如转载,请注明本文链接: http://newmiracle.cn/?p=1285

发表评论

电子邮件地址不会被公开。 必填项已用*标注