Skip to content

BUNara/JavaTTLCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Œ README.md md Copy Edit

πŸ—οΈ Spring Boot Thread-Safe TTL Cache API

This repository provides a Spring Boot starter project for implementing a Thread-Safe In-Memory Cache with TTL (Time-To-Live) Eviction.


πŸ› οΈ Installation & Setup

1️⃣ Prerequisites

Ensure you have the following installed:

2️⃣ Clone the Repository

git clone https://github.com/BUNara/JavaTTLCache.git

cd JavaTTLCache

3️⃣ Build the Project

mvn clean install

4️⃣ Run the Spring Boot Application

mvn spring-boot:run

http://localhost:8080

πŸ“Œ Task Overview

Your task is to implement a thread-safe in-memory cache that supports:

1️⃣ Storing key-value pairs

2️⃣ Retrieving values from the cache

3️⃣ Automatically expiring cache entries after a specified TTL (Time-To-Live)

4️⃣ Exposing REST API endpoints to interact with the cache

πŸ“Œ Requirements

The cache should be thread-safe and handle concurrent access.

Entries should expire automatically after 60 seconds.

The cache should be accessible via a REST API with the following endpoints:

API Endpoints

Method Endpoint Description

  • PUT /cache/{key} Stores a value in the cache
  • GET /cache/{key} Retrieves a value (returns 404 if expired)
  • DELETE /cache/{key} Removes a value from the cache

πŸ“‚ Project Structure

.
JavaTTLCache/
│── src/main/java/com/example/ttlcache/
β”‚   β”œβ”€β”€ CacheService.java      # Implement your caching logic here
β”‚   β”œβ”€β”€ CacheController.java   # Implement API endpoints here
│── src/main/resources/
β”‚   β”œβ”€β”€ application.properties # Configuration settings (optional)
│── pom.xml                    # Maven dependencies
│── README.md                   # Instructions for candidates

πŸ“© Submitting Your Solution

Fork this repository.

Implement your solution in CacheService.java and CacheController.java.

Push your changes and share the GitHub repo link.

πŸ“Œ Notes

You can use any approach to ensure thread safety and TTL expiration.

Follow REST API best practices.

The correctness, performance, and maintainability of your solution will be evaluated.

πŸš€ Good luck! Looking forward to your implementation!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages