This repository consist the simple example of springboot crud application using redis cache
Minimal Spring Boot sample app.
For building and running the application you need:
git clone https://github.com/deepak-kumbhar/springboot-redis-cache.git
There are several ways to run a Spring Boot application on your local machine. One way is to execute the main
method in the com.example.redis.SpringbootRedisApplication
class from your IDE.
Alternatively you can use the Spring Boot Maven plugin like so:
mvn spring-boot:run
- Add blog
Request:
[
{
"id":1,
"title":"changed blog name",
"author":"deepak",
"content":"this is blog 1 content",
"tags":["java","learning"]
}
]
Response:
{
"id": 1,
"title": "changed blog name",
"author": "deepak",
"content": "this is blog 1 content",
"tags": [
"java",
"learning"
]
}
- Get blog by id Request:
Add blog id in path param
Response:
{
"id": 1,
"title": "changed blog name",
"author": "deepak",
"content": "this is blog 1 content",
"tags": [
"java",
"learning"
]
}
Now if you look on the console log message, according to that at first time when you try to get blog it will fetch blog details from DB and when you try again it will fetch the same data from cache as no console log will be going to print.
When you make any changes(Update) in the same object, then it will update the data and update the cache as well.