Pavan Kumar R R Pavan Kumar R R - 1 year ago 112
Java Question

How to push complex java objects to Redis using lettuce 4.2 Cluster client

I have a complex java object with all types of data types. We need to push this object to Redis cache with string as key and value is this object. We have Redis cluster of 6 machines.

How to push this object through java code using lettuce cluster client?

Answer Source

You have two options:

  1. You perform serialization (JDK serialization, JSON, Protobuf, ...) on your own. You can do that before sending data to Redis, or you implement an own RedisCodec that does the job (see
  2. Use a framework in front of lettuce (such as Spring Data Redis). Spring Data Redis comes with various codecs that provide serialization out of the box.