PHP code example of vivlong / phalapi-redis2

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

    

vivlong / phalapi-redis2 example snippets


    /**
     * 扩展类库 - Redis扩展
     */
    'Xredis' => array(
        //Redis链接配置项
        'servers'  => array(
            'host'   => '127.0.0.1',        //Redis服务器地址
            'port'   => '6379',             //Redis端口号
            'prefix' => 'PhalApi_',         //Redis-key前缀
            'auth'   => 'phalapi',          //Redis链接密码
        ),
        // Redis分库对应关系操作时直接使用名称无需使用数字来切换Redis库
        'DB'       => array(
            'developers' => 1,
            'user'       => 2,
            'code'       => 3,
        ),
        //使用阻塞式读取队列时的等待时间单位/秒
        'blocking' => 5,
    ),

$di->cache = function () {
    return new \PhalApi\Xredis\Lite(\PhalApi\DI()->config->get("app.Xredis.servers"));
};