What is the best way to store a nested and complex java object in Redis. The way we are doing is as follows.
We are using Redisson java client library for Redis interactions. Please see the code below :
try{
Config conf = new Config();
conf.useSingleServer().setTimeout(3600000);
conf.useSingleServer().setRetryInterval(3600000);
conf.useSingleServer().setAddress("redis://127.0.0.1:6379");
RedissonClient redisson = Redisson.create(conf);
RMap<String,Object> map = redisson.getMap("myCache");
MyClass myObject; // This is the big complex object.
map.put("key", myObject);
redisson.shutdown();
}catch (Exception ex) {
ex.printStackTrace();
}
Similarly, instead of put, we are using get to fill our myObject from redis.
We have increased the timeouts because of big size data being stored in redis, We were getting following exception :
Command execution timeout for command: (EVAL) with params...
Please answer the following questions as well :
- Is this the best way to put huge complex java objects in Redis? (The data can be around 1GB)
- Our team is new to Redis, We have read the good performance given by Redis, Should we use it to store complex data or it is good only in case of small single String as the value? (If So, what is Advised for our use case)
Thanks.