【原】修改Redis操作类,支持选择数据库功能

版本3.2.2(ThinkPHP\Library\Think\Cache\Driver\Redis.class.php),官方默认不支持选择数据库功能,现就可选择数据库功能进行说明。

  1. 1 config.php  配置文件中选择数据库 

     'REDIS_DBINDEX' =>1, // 默认0,dev 1号,test2号

  1. 2 Redis.class.php中修改__construct()方法

    'dbindex'    => C('REDIS_DBINDEX') ? C('REDIS_DBINDEX') : 0;   //选择存库

    $this->options['dbindex'] = isset($options['dbindex'])? $options['dbindex'] : 0;   //选择存库

    $this->handler->select($this->options['dbindex']);   //选择存库

 

代码如下所示:

猜你喜欢

转载自www.cnblogs.com/HYanqing/p/9618401.html
今日推荐