Redis connector


Redis connector

Parent document: Connectors

BitSail Redis connector supports writing Redis. The main function points are as follows:

  • Support batch write to Redis.
  • Support 4 kinds of data type in Redis.

Maven dependency

<dependency>
   <groupId>com.bytedance.bitsail</groupId>
   <artifactId>bitsail-connector-redis</artifactId>
   <version>${revision}</version>
</dependency>

Redis writer

Supported data types

We support four kinds of data types in Redis:

  • String, Set, Hash, Sorted Set.

Each data type has its own requirement for input data:

Data typeRequired column numbers1st column2nd column3rd column
String2keyvalue
Set2key of setvalue to insert into set
Hash3key of hashkey to insert to hashvalue to insert to hash
Sorted Set (Zset)3key of Sorted setscorevalue to insert to set

Tips: If there are more than 3 columns, Mhash can be used.

Parameters

The following mentioned parameters should be added to job.writer block when using, for example:

{
  "job": {
    "writer": {
      "class": "com.bytedance.bitsail.connector.legacy.redis.sink.RedisOutputFormat",
      "redis_data_type": "string",
      "redis_host": "localhost",
      "redis_port": 6379
    }
  }
}

Necessary parameters

Param nameRequiredOptional valueDescription
classYesClass name of redis writer, com.bytedance.bitsail.connector.legacy.redis.sink.RedisOutputFormat
redis_hostYeshost of redis
redis_portYesport of redis

Optional parameters

Param nameRequiredOptional valueDescription
writer_parallelism_numNoWriter parallelism num
client_timeout_msNoTimeout of redis connection. Default 60000 ms
ttlNoTtl of inserted data. Default -1 means not setting ttl
ttl_typeNo"DAY", "HOUR", "MINUTE", "SECOND"Time unit of ttl. Default "DAY"
write_batch_intervalNoRedis instruction write batch size. Default 50
redis_data_typeNo"string"
"set"
"hash"
"sorted_set"
"mhash"
Data type to insert. Default "string"
passwordNoPassword of redis

Configuration examples: Redis connector example