Tp5 配置 Redis 
                                                    
                        
                    
                    
  
                    
                    安装redis
配置Redis访问密码
Linux下的 /usr/local/redis-3.0.7/redis.conf
编辑配置文件vim redis.conf
输入/requirepass进行搜索关键字;按键n跳至下一个匹配
找到# requirepass foobared ,把#去掉, foobared改成自己的密码即可
:wq保存修改,退出
在/usr/local/redis-3.0.7/src路径下重启redis:redis-server  ../redis.conf
Tp5配置redis
配置config.php文件
//redis配置
'cache' =>  [
    // 驱动方式
    'type'   => 'redis',
    // 服务器地址
    'host'   => '这里填服务器ip',
    // 端口号
    'port'    => 6379,
    // redis配置的密码,如果没有则留空
    'password'  => '这里填密码',
    // 缓存保存目录
    'path'   => CACHE_PATH,
    // 缓存前缀
    'prefix' => '',
    // 缓存有效期 0表示永久缓存
    'expire' => 0,
],测试
<?php
namespace app\index\controller;
use think\Cache;
class Index
{
    public function test()
    {
        Cache::set('name:a','bilibili');
        halt(Cache::get('name:a'));   // bilibili
    }
}本作品采用《CC 协议》,转载必须注明作者和本文链接
 
           阿江 的个人博客
 阿江 的个人博客
         
           
           关于 LearnKu
                关于 LearnKu
               
                     
                     
                     粤公网安备 44030502004330号
 粤公网安备 44030502004330号 
 
推荐文章: