VJS
VJS

Reputation: 2951

Spring data redis (with lettuce) advantages for creating wrapper library

I am new to Redis and planning to use it as in memory cache. I am using Lettuce 5.2 client for it.

I have multiple applications which will use redis as in memory cache. My idea is to write library using lettuce like wrapper which can be used by multiple application in order to interact with Redis. That library will manage connection pooling, redis failover cases and command execution etc. so that application writer should not worry about all this and just need to use my library.

Now for this library i am confused on below points :

1) Should i use Spring data redis (it also supports lettuce)? If my objective is to create library then first of all, can i use spring data redis ?

2) What all advantage Spring data redis will give me. I have checked documentation https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#reference

3) If i don't use Spring data redis then I will just use only lettuce and create client, connention pool etc myself.

I am confused whether i should use spring data redis for creating library or not ?

Can you please help me to clear my confusion ?

Upvotes: 0

Views: 1024

Answers (1)

Derrops
Derrops

Reputation: 8117

You are able to implement custom Repository methods in Spring Data, which has been outlined in other answers on SO such as here: How to add custom method to Spring Data JPA.

So you can easily combine both the out of the box Spring Data Redis functionality with custom Lettuce method code for a Spring Data Repository, I would suggest starting with Spring Data, and if you need to fine tune anything beyond that then write a custom methods with Lettuce.

So long as you can use the same connection pool in Lettuce as Spring Data Redis, you should be able to share that as a resource, the same way you can consider Threads as a resource.

No one can really give you a yes no answer as to what libraries you should or shouldn't use, hopefully you have enough information now to make progress going forward.

Upvotes: 0

Related Questions