@Experimental(value=SOURCE_SINK) public class RedisIO extends java.lang.Object
read() provides a source which returns a bounded PCollection containing
key/value pairs as KV<String, String>.
To configure a Redis source, you have to provide Redis server hostname and port number. Optionally, you can provide a key pattern (to filter the keys). The following example illustrates how to configure a source:
pipeline.apply(RedisIO.read()
.withEndpoint("::1", 6379)
.withKeyPattern("foo*"))
It's also possible to specify Redis authentication and connection timeout with the corresponding methods:
pipeline.apply(RedisIO.read()
.withEndpoint("::1", 6379)
.withAuth("authPassword")
.withTimeout(60000)
.withKeyPattern("foo*"))
readAll() can be used to request Redis server using input PCollection elements as key
pattern (as String).
pipeline.apply(...)
// here we have a PCollection<String> with the key patterns
.apply(RedisIO.readAll().withEndpoint("::1", 6379))
// here we have a PCollection<KV<String,String>>
write() provides a sink to write key/value pairs represented as KV from an
incoming PCollection.
To configure the target Redis server, you have to provide Redis server hostname and port number. The following example illustrates how to configure a sink:
pipeline.apply(...)
// here we a have a PCollection<String, String> with key/value pairs
.apply(RedisIO.write().withEndpoint("::1", 6379))
| Modifier and Type | Class and Description |
|---|---|
static class |
RedisIO.Read
Implementation of
read(). |
static class |
RedisIO.ReadAll
Implementation of
readAll(). |
static class |
RedisIO.Write
A
PTransform to write to a Redis server. |
| Modifier and Type | Method and Description |
|---|---|
static RedisIO.Read |
read()
Read data from a Redis server.
|
static RedisIO.ReadAll |
readAll()
Like
read() but executes multiple instances of the Redis query substituting each
element of a PCollection as key pattern. |
static RedisIO.Write |
write()
Write data to a Redis server.
|
public static RedisIO.Read read()
public static RedisIO.ReadAll readAll()
read() but executes multiple instances of the Redis query substituting each
element of a PCollection as key pattern.public static RedisIO.Write write()