phpredis单例模式封装

通过单例模式实现对phpredis连接的封装。

直接上代码

connRedis();
    }

    /**
     * 连接ocean 上的redis的私有化方法
     * @return Redis
     */
    static private function connRedis()
    {
        try {
            $redis_ocean = new Redis();
            $redis_ocean->connect(G::$conf['redis-host'], G::$conf['redis-port']);
            $redis_ocean->auth(G::$conf['redis-pass']);

        }catch (Exception $e){
            echo $e->getMessage().'
'; } return $redis_ocean; } }

【转载请注明:phpredis单例模式封装 | 靠谱崔小拽 】

你可能感兴趣的:(单例模式,设计模式,php,redis)