An example PERSON RESTful API built on Spring Boot.
- RESTful API.
- Models with proper relationships.
- Controllers/Models etc with proper separation.
- oauth Authentication, used inMemoryAuthentication.
- Hibernate used for ORM.
- AngularJS v1.3, Bootstrap v3.3.7 used for Front end.
- For testing, H2 database used.
- Proper Integration Test.
Redis cache is used for cache management feature offered by Redis. Redis is normally used as a cache to store repeatedly accessed data in memory so that to increase our application performance.
We apply this annotation at the main class (starter class) of our application in order to tell Spring Container that we need Caching feature in our application.
@Cacheable is used to fetch data from the DB to application and store in Redis Cache.
We use @CachePut in order to update data in the redis cache while there is any update of data in DB.
We use @CachePut in order to remove data from Redis Cache while there is any removal of data in DB.
The below dependency add caching support and bring in all the required dependencies.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
Follow the link : https://redis.io/topics/quickstart
Getting started with Redis is quite easy and straightforward. Using Homebrew, you can get it up and running within a couple of commands:
To install Redis on Mac: brew install redis
Start Redis server: brew services start redis
Stop Redis server: brew services stop redis
Restart Redis server: brew services restart redis
Run command redis-cli ping. If response to this command is PONG, your redis server is running ok.
ULR: http://localhost:8080/api/v1/home
METHOD | PATH | DESCRIPTION |
---|---|---|
POST | /oauth/token | get oauth token to access the API |
GET | /api/v1/persons/?access_token={token_value} | get all person list |
GET | /api/v1/persons/{person_id}?access_token={token_value} | get person details by ID list |
POST | /api/v1/persons/?access_token={token_value} | save person details |
PUT | /api/v1/persons/?access_token={token_value} | update person |
DELETE | /api/v1/persons/{person_id}?access_token={token_value} | delete person |