Cache java POJOs in AWS redis using RedissonClient

I have a requirement to cache the entity object (as JSON String) in order to save database hits.

I want to use AWS Redis as cache server and RedissonClient.

I am new to this caching.. Can you please tell me what is a best approach to cache these java POJO ? as RedissonClient has functionality like bucket, map list etc..

Also let me know what are the other thing one should look for while using AWS REDIS.

Thanks in advance!!

Upvotes: 0

Views: 1381

Answers (1)

Kush Vyas
Kush Vyas

Reputation: 6099

As this can be seen as generic question , I will try to answer in way as simple as possible:

Redisson is good choice and would work well in above described usecase (Redis based framework for Java) works with POJO objects and you don't need to serialize/deserialize object by yourself each time and work with connections (acquire/release). It's all done by the Redisson.

This can be an example :

RBucket<AnyObject> bucket = redisson.getBucket("anyObject"); 
// set an object 
bucket.set(new AnyObject()); 
// get an object 
AnyObject myObject = bucket.get();

Now to give you an option alternatively you can read LiveObjectService

And to answer the orignal question about codec supports , Redisson supports many popular codecs like Jackson JSON, Avro, Smile, CBOR, MsgPack, Kryo, FST, LZ4, Snappy and JDK Serialization.

Hope this helps

Upvotes: 4

Related Questions