PHP code example of v10086 / redis

1. Go to this page and download the library: Download v10086/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/ */

    

v10086 / redis example snippets




        //设置配置信息
        \v10086\Redis::$config=[
                'default'=>[
                    'host'          =>  'redis',//地址
                    'port'          => '6379',//端口
                    'password'      =>'pass',//密码
                    'persistent'    =>TRUE, //是否长连接  true 是 false 否
                    'timeout'=>FALSE
                ],
                'other'=>[
                    'host'          =>  'other_redis',//地址
                    'port'          => '6379',//端口
                    'password'      =>'other_pass',//密码
                    'persistent'    =>TRUE, //是否长连接  true 是 false 否
                    'timeout'=>FALSE
                ],
        ];
        //默认default 可设置为其他配置
        \v10086\Redis::connection('default');

        //句柄所具备的操作函数跟redis官方所提供的命令一致,可到redis官网查阅
        \v10086\Redis::set('key','val');
        \v10086\Redis::get('key');