This project implements a flexible and efficient cache system that supports multiple eviction policies such as Least Recently Used (LRU), Least Frequently Used (LFU), and Time-To-Live (TTL). It provides a generic caching mechanism with pluggable eviction strategies, ensuring scalability and performance optimization.
- Supports LRU, LFU, and TTL-based eviction policies.
- Implements the Strategy Pattern to dynamically select eviction strategies.
- Follows SOLID principles for maintainability and extensibility.
- Includes Static Code Analysis using SpotBugs, PMD, Checkstyle, and JaCoCo.
The cache system follows the Strategy Pattern by encapsulating different eviction policies into separate classes, allowing dynamic selection of an eviction strategy at runtime via the CacheFactory class.
- Single Responsibility Principle (SRP): Each class has a single, well-defined responsibility (e.g.,
GenericCache
manages storage,EvictionPolicy
handles eviction logic,CacheFactory
creates cache instances). - Open-Closed Principle (OCP): New eviction policies can be added without modifying the existing cache logic, as they extend the
EvictionPolicy<K>
interface. - Liskov Substitution Principle (LSP): The generic cache interacts with any eviction policy interchangeably without affecting functionality.
- Interface Segregation Principle (ISP): The
Cache<K, V>
interface provides only essential cache operations, avoiding unnecessary dependencies. - Dependency Inversion Principle (DIP): The cache system depends on the abstraction (
EvictionPolicy<K>
) rather than concrete implementations of eviction policies.
- Java 17+
- Maven
git clone https://github.com/hasinghgrid/cache-system.git
cd cache-system
mvn clean install
java -jar target/cache-system.jar
Detects potential bugs and performance issues in the codebase.
Analyzes code style, best practices, and potential optimizations.
Ensures coding standard compliance based on Java style guidelines.
Measures code coverage to track test effectiveness.
