Lettuce Core API has RedisClient class that contains these methods:
public StatefulRedisConnection<String, String> connect() {
return this.connect(this.newStringStringCodec());
}
public <K, V> StatefulRedisConnection<K, V> connect(RedisCodec<K, V> codec) {
this.checkForRedisURI();
return (StatefulRedisConnection)this.getConnection(this.connectStandaloneAsync(codec, this.redisURI, this.timeout));
}
I want to call method connect(RedisCodec<K, V> codec)
, but I don't know how to config my codec object that I should pass as a parameter to this method.
My current code:
val redisClient = RedisClient.create("redis://password@localhost:6379/0");
val connection = redisClient.connect();
// in this case type of connection is StatefulRedisConnection<String, String>
val redisCommands = connection.sync()
I also has my custom data class.
data class MyCustomDataClassName {
val id: UUID,
val something: String,
val foo: String,
val bar: String
}
I want to write this code:
val redisClient = RedisClient.create("redis://password@localhost:6379/0");
val codec = /* should be something that returns object of type StatefulRedisConnection<String, MyCustomDataClassName>*/
val connection = redisClient.connect(codec);
val redisCommands = connection.sync()