Reputation: 117
I have 2 layer spring
boot application as below and wish to implement distributed 2nd level cache with redis
as to improve the performance .
[Spring boot Architecture][1]
Here we are using kubernates
and hence there could be multiple instances of "Atomic Service A" and hence the requirement of distributed cache.
Though there could be few requests coming less frequently to modify the data in DB and same needs to be reflected in cache
.
Wondering if there is any standard solution with redis
to fetch data as like from traditional RDBMS
.
Here the hypothetical solution would be like on startup "Student Atomic Service A" shall load Student data from DB on Redis cache
and then any subsequent delete/update shall first do the same in Db and then update in Redis
also I should get the records from Redis
the way we query RDBMS
.
e.g select * from student where id <10
It would be great if anybody can point any hint of sample implementation here.
I have gone through various sites but they only talk about key value thing but wish to find a DB Query like solution where the queried result shall get returned from cache.
I have tried POC with RedisTemplate
but do not find a api like the way we query to a DB can be made e.g. select * from student where id<=5
Do not see any API
which shall allow me to do operations like RDBMS
with redis cache API
Upvotes: 1
Views: 1592
Reputation: 9102
Do not see any API which shall allow me to do operations like RDBMS with redis cache API
Typical RDBMS ( like MySQL, Oracle etc.) and Redis are different datastores with different data models and query language so they have virtually nothing in common except they are persistent data stores. You can have two different level of abstractions integrating with these data stores. One abstraction is at a repository level - what framework like Spring Data Redis provides.For Spring Data Redis repository check here. Another abstraction is provided by framework like Hibernate Data which provides integration with Redis via Hibernate OGM Redis module. This is more close to what you are expecting as it will give you a rich JPQL query language ( which is very close to SQL except that it operates on Objects rather than tuples). This may be worth checking out.
Upvotes: 1