title: Redis coroutine client meta:

  • name: description content: Redis coroutine client,Implemented by swoole coroutine client,Covers the method of redis 99%
  • name: keywords content: swoole|swoole extension|swoole framework|EasySwoole redis| Swoole Redis coroutine client|swoole Redis|Redis coroutine

Configuration

redis configuration

When redis is instantiated, you need to pass in the \EasySwoole\Redis\Config\RedisConfig instance:

  1. $config = new \EasySwoole\Redis\Config\RedisConfig([
  2. 'host' => '127.0.0.1',
  3. 'port' => '6379',
  4. 'auth' => 'easyswoole',
  5. 'db' => null,
  6. 'serialize' => \EasySwoole\Redis\Config\RedisConfig::SERIALIZE_NONE
  7. ]);

The configuration items are as follows:

Configuration name Default parameter Description Notes
host 127.0.0.1 Redis ip
port 6379 Redis port
auth Auth password
db null Redis database When the db configuration is not equal to null, the configuration will be automatically selected when connected
timeout 3.0 overtime time
reconnectTimes 3 Client abnormal reconnection times
serialize SERIALIZE_NONE Whether the data is serialized

::: warning Serialization parameters are: SERIALIZE_NONE, SERIALIZE_PHP, SERIALIZE_JSON :::

redis cluster configuration

When the redis cluster is instantiated, you need to pass in the \EasySwoole\Redis\Config\RedisConfig instance:

  1. $config = new \EasySwoole\Redis\Config\RedisClusterConfig([
  2. ['172.16.253.156', 9001],
  3. ['172.16.253.156', 9002],
  4. ['172.16.253.156', 9003],
  5. ['172.16.253.156', 9004],
  6. ], [
  7. 'auth' => '',
  8. 'serialize' => \EasySwoole\Redis\Config\RedisConfig::SERIALIZE_PHP
  9. ]);

::: warning The cluster configuration first passes a multi-dimensional array of ip and port, and then passes other configuration items. Other configuration items are consistent with redis configuration. :::