Thinkphp是有redis的类的
Redis.class.php在Thinkphp/Library/Think/Cache/Driver/Redis.class.php
里面封装了一些redis的方法。
在控制器中new的时候要注意:
use Think\Cache\Driver\Redis;
$redis = new Redis();
不要new成了源生的redis类。
3.2的redis类没有设密码,我修改过了这个类:
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- namespace Think\Cache\Driver; use Think\Cache; defined('THINK_PATH') or exit(); /** * Redis缓存驱动 * 要求安装phpredis扩展:https://github.com/nicolasff/phpredis */ class Redis extends Cache { /** * 架构函数 * @param array $options 缓存参数 * @access public */ public function __construct($options=array()) { if ( !extension_loaded('redis') ) { E(L('_NOT_SUPPORT_').':redis'); } $options = array_merge(array ( 'host' => C('REDIS_HOST') ? : '127.0.0.1', 'port' => C('REDIS_PORT'</