📌 README.md md Copy Edit
This repository provides a Spring Boot starter project for implementing a Thread-Safe In-Memory Cache with TTL (Time-To-Live) Eviction.
Ensure you have the following installed:
- Java 17+ → Download JDK
- Maven → Install Maven
- Git → Install Git
- An API testing tool like Postman or cURL
git clone https://github.com/BUNara/JavaTTLCache.git
cd JavaTTLCache
mvn clean install
mvn spring-boot:run
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
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.
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.