Reputation: 49954
I am using this Flink Redis sink version dependency:
<dependency>
<groupId>org.apache.bahir</groupId>
<artifactId>flink-connector-redis_2.11</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
Here is my current code:
public static class MyRedisMapper implements RedisMapper<Tuple2<String, String>>{
@Override
public RedisCommandDescription getCommandDescription() {
return new RedisCommandDescription(RedisCommand.HSET, "MY_REDIS_KEY");
}
@Override
public String getKeyFromData(Tuple2<String, String> data) {
return data.f0;
}
@Override
public String getValueFromData(Tuple2<String, String> data) {
return data.f1;
}
}
FlinkJedisPoolConfig conf = new FlinkJedisPoolConfig.Builder().setHost("127.0.0.1").build();
DataStream<String> myStream = ...;
myStream.addSink(new RedisSink<Tuple2<String, String>>(conf, new MyRedisMapper());
Currently after writing data to Redis, the data will stay there and won't expire.
I hope to set Redis TTL to make keys expire.
The official doc is very simple.
After reading it, I still have no clue.
How to set TTL to make my Redis keys expire? Thanks!
UPDATE:
When I check the Java class I am using, I only have
public RedisCommandDescription(org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommand redisCommand, java.lang.String additionalKey) { /* compiled code */ }
public RedisCommandDescription(org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommand redisCommand) { /* compiled code */ }
However, I found a pull request that add TTL to HSET
and also a new SETEX
command, got merged in Oct 2019.
I didn't see SETEX
got added in the doc https://bahir.apache.org/docs/flink/current/flink-streaming-redis/
Also, I didn't find this line that in the part of pull request:
public RedisCommandDescription(RedisCommand redisCommand, String additionalKey, Integer additionalTTL)
in my current version dependency.
I didn't find a new flink-connector-redis version in the Maven.
Where can I find and use the latest version of flink-connector-redis?
Upvotes: 0
Views: 578
Reputation: 201
unfortunately version 1.0 is the latest release so you'll need to build the connector from the sources
Best, D.
Upvotes: 1