PHP code example of edward1108 / edward-redis

1. Go to this page and download the library: Download edward1108/edward-redis library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

edward1108 / edward-redis example snippets


config/redis.php
return [
    // 缓存前缀
    'prefix'        => '',
    // 缓存有效期 0表示永久缓存,单位:秒
    'expire'        => 0,
    // redis主机
    'host'          => '127.0.0.1',
    // redis端口
    'port'          => '',
    // 密码
    'password'      => '',
    // 操作库
    'select'        => 0,
    // 超时时间(秒)
    'timeout'       => 0,
    // 是否长连接
    'persistent'    => false,
];

config.php
'redis'                  => [
    // 缓存前缀
    'prefix'        => '',
    // 缓存有效期 0表示永久缓存,单位:秒
    'expire'        => 0,
    // redis主机
    'host'          => '127.0.0.1',
    // redis端口
    'port'          => '',
    // 密码
    'password'      => '',
    // 操作库
    'select'        => 0,
    // 超时时间(秒)
    'timeout'       => 0,
    // 是否长连接
    'persistent'    => false,
]


    namespace app\index\controller;
    use edward-redis\Redis;

    class index
    {
        public function test()
        {
            Redis::set('name','edward-redis');
            $res = Redis::get('name');
            var_dump($res);  //输出edward-redis代表成功
        }
    }