zoukankan      html  css  js  c++  java
  • 【原】thinkphp修改Redis操作类,支持选择数据库功能及添加其他方法

    版本3.2.2(ThinkPHPLibraryThinkCacheDriverRedis.class.php),

    一:官方默认不支持选择数据库功能及,现就可选择数据库功能进行说明。

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

         'REDIS_DBINDEX' =>1, // 选择库信息(0~16)

    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']);   //选择存库

    二:官方默认未实现鉴权功能,现就实现鉴权进行说明。

    1. 1 config.php  配置文件中增加鉴权密码

        'REDIS_AUTH'=>'123456', //AUTH认证密码

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

        if($this->options['auth']!=null){

          $this->handler->auth($this->options['auth']); //说明有配置redis的认证配置密码 需要认证

        }

    三:具体代码如下:

     

     

     

  • 相关阅读:
    【MySQL笔记】字符串、时间日期转换
    【MySQL笔记】触发器,存储过程和函数
    【MySQL笔记】用户管理
    spray 处理 response 的通用函数
    akka pubsub example
    一个手写的 http client
    scala get ipv4 address
    akka cluster singleton
    akka cluster sharding
    akka cluster 初体验
  • 原文地址:https://www.cnblogs.com/HYanqing/p/9618401.html
Copyright © 2011-2022 走看看