What are the best parameters that can be used in lettuce here: #2109
-
I'd like to know if there is currently anything I could change in the lettuce redis client parameters in order to improve the performance: I'm currently using these methods here: This is to initialize the client redisClient = RedisClient.create(RedisURI.builder().withHost(host).withPort(port)
.withPassword(password).withDatabase(0)
.withTimeout(Duration.ofSeconds(30000)).build());
sender = redisClient.connect(new ByteArrayCodec()); This is to publish messages ( I know i could do this with pipelines, just don't know how to public void publishData(byte[] channel,byte[] message){
Executor.submit(()-> sender.sync().publish(channel,compress(message)));
} Registering my pubsub public void registerPubSub(RedisPubSubAdapter<byte[],byte[]> sub, byte[] ... names){
Thread thread = new Thread(()-> {
StatefulRedisPubSubConnection<byte[],byte[]> connection = redisClient.connectPubSub(new ByteArrayCodec());
connection.addListener(sub);
RedisPubSubAsyncCommands<byte[],byte[]> pubSubCommands = connection.async();
pubSubCommands.subscribe(names);
});
pubsubs.add(thread);
thread.setDaemon(true);
thread.start();
} The pipeline usage would mostly just improve the time response of the thread and not blocking it until the response arrives, correct? (Are there any other improvements else than that?) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Subscribing with Lettuce doesn't require an additional thread as the Calling RedisPubSubAsyncCommands<byte[],byte[]> pubSubCommands = connection.async();
pubSubCommands.subscribe(names) on the main thread is fully sufficient. Other than that, you can call |
Beta Was this translation helpful? Give feedback.
Subscribing with Lettuce doesn't require an additional thread as the
subscribe
method doesn't block.Calling
on the main thread is fully sufficient. Other than that, you can call
sender.async().publish(channel,compress(message))
to not await completion of thePUBLISH
command (fire&forget).