PHP code example of livenux / think-redis-cluster

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

    

livenux / think-redis-cluster example snippets

 php


return [
    "default" => "redis_cluster",
    "stores" => [
        "redis_cluster" => [
            "type" => "livenux\\RedisCluster",
            "servers" => ["127.0.0.1:7000", "127.0.0.1:7001", "127.0.0.1:7002"],
            "read_type" =>  "failover", // 读写分离选项, key的读写类型, 默认random, 可选: random, slaves, master, failover, 建议采用 failover 主从延迟的情况下 thinkphp 会报错
            "timeout" => 1.5, // 连接超时时间
            "read_timeout" => 1.5, // 读超时时间
            "expire" => 7200, // 缓存有效时间
            "prefix" =>  "think:", // 缓存前缀
            "password" => '', // 用户认证密码
            "ssl" => false, // 是否使用SSL
            "persistent" => true, // 是否使用持久化连接
            "ssl_context" => null, // SSL上下文选项
            "compression" => "lz4", // 压缩选项, 可选: lzf, lz4, zstd, 默认不压缩
        ],
    ],

];