- Install openjdk-8 and maven.
- Install dependencies using
mvn clean install
- Run the application with
mvn spring-boot:run
-
Endpoint:
GET /books/{id}
-
Description: Retrieves a
Book
by its identifier. -
Path Parameters:
id
(String): The identifier of theBook
to retrieve.
-
Response:
- 200 OK: The
Book
with the specified identifier.
- 200 OK: The
-
Example Request:
GET /books/123abc
-
Example Response:
{ "id": "123abc", "name": "The Great Gatsby", "author": "F. Scott Fitzgerald", "price": 10.99 }
-
Endpoint:
POST /books
-
Description: Adds a new
Book
to the system. -
Request Body:
- Content-Type:
application/json
- Body: The
Book
object to add.
- Content-Type:
-
Response:
- 201 Created: The added
Book
.
- 201 Created: The added
-
Example Request:
POST /books Content-Type: application/json { "name": "1984", "author": "George Orwell", "price": 8.99 }
-
Example Response:
{ "id": "456def", "name": "1984", "author": "George Orwell", "price": 8.99 }
-
Endpoint:
DELETE /books/{id}
-
Description: Removes a
Book
from the system by its identifier. -
Path Parameters:
id
(String): The identifier of theBook
to remove.
-
Response:
- 204 No Content: The
Book
was successfully removed.
- 204 No Content: The
-
Example Request:
DELETE /books/123abc
-
Endpoint:
GET /books/cache/size
-
Description: Retrieves the current size of the cache.
-
Response:
- 200 OK: An integer representing the number of entries currently in the cache.
-
Example Request:
GET /books/cache/size
-
Example Response:
10
-
Endpoint:
DELETE /books/cache
-
Description: Clears all entries from the cache.
-
Response:
- 204 No Content: The cache was successfully cleared.
-
Example Request:
DELETE /books/cache