Skip to content

code123-tech/Spring_Boot_Cache_Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-boot-redis-example

Spring Boot Application with Redis Cache Example

Introduction

As of right now, we are aware that typical users need a quicker response time and improved programme performance. What if we make an unnecessary query request to the database in this situation? (When we are fetching the same data again and again in the different calls). What if, instead of doing this, we stored the data that does not change frequently somewhere where it could be retrieved more quickly than a database? As a result, we can store the data in memory, and memory retrieval is quicker than database retrieval.

In essence, it is known as

Storing the frequently used DB data into memory so that 
we may load data straight from memory to increase speed 
and reaction time.

Functionalities

  • We can Add a new User inside the Database.
  • We can retrieve the single user details.
  • We can fetch users list with any number of users on a single page.
  • Implementation of caching on fetching of users list so that fetching can be faster than usual.

API Endpoints

  1. /add-user: In this POST request, we can add a new user with the following informations.

     {
         "firstName": "example",
         "lastName" : "finish",
         "email"    : "example123@gmail.com",
         "mobile"   : "8888888888"
     }
    
  2. /users/{userId}: In this GET Request, you need to pass the valid userId to fetch the User.

  3. /users/{userId}: In this DELETE Request, you can delete the User with which exist in the DB, and it will be flushed from Cache.

  4. /users?page=<>: In this GET Request, you can get 1000 Users on each page, and you need to pass valid page number.

  5. /users/{userId}: In this PUT Request, you can update the user details which exist with user Id in the DB.

     {
         "firstName": "example",
         "lastName" : "finish",
         "email"    : "example123@gmail.com",
         "mobile"   : "8888888888"
     }
    
  6. /query-users?queryEmail=<>&limit=<>: In this GET Request, you can fetch the users whose email contains queryEmail character, and per page limit can be send in queries.

Points

  • UserDao is separate layer used for caching.

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages