thinkphp5 集成redis, SESSION用redis session.save_path = "tcp://127.0.0.1:6379?auth=password"

首先要配置php-redis扩展

https://blog.csdn.net/fareast_mzh/article/details/81463749

 

配置文件:

application/config.php

增加配置:

    // +----------------------------------------------------------------------
    // | 缓存设置
    // +----------------------------------------------------------------------

    'cache'                  => [
        'type'   => 'redis',
        // 服务器地址
        'host'   => '172.16.0.224',
        'port'   => 16379,
        'password'   => '******',
        'select'     => 0,
        'timeout'    => 3,
        'expire'     => 3600,
        'persistent' => false,
        'prefix'     => '',
    ],

persistent 表示是不是用pconnect长连接到redis

 

用法:

application/index/model/Employee.php

你可能感兴趣的:(redis,php,redis,thinkphp)