thinkphp5.0 redis 配置账号密码使用

2019-01-23  本文已影响0人  someonemaybe

class Redis

{

    static private $instance;

    private function __construct()

{

}

    static public function getInstance()

{

        if (!self::$instance instanceof self){

            self::$instance = (new \think\cache\driver\Redis([

                'host'      => config('cache.host'),

                'port'      => config('cache.port'),

                'password'  => config('cache.password'),

                'select'    => 0,

                'timeout'    => 0,

                'expire'    => 0,

                'persistent' => false,

                'prefix'    => '',

]))->handler();

}

        return self::$instance;

}

    private function __clone()

{

}

}

上一篇下一篇

猜你喜欢

热点阅读