Skip to content

nicolasanelli/super-cache-evict

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Super Cache Evict

A Spring Boot proof of concept (POC) focused on advanced distributed cache eviction strategies using Redis, centered around a custom annotation:

🔥 @SuperCacheEvict

This project was built to experiment with and demonstrate a more powerful and flexible cache eviction mechanism on top of Spring’s default cache abstraction.


🚀 The Core Idea

Spring provides @Cacheable and @CacheEvict, which work well for simple scenarios.

However, in real-world distributed systems, eviction often requires:

  • Multiple related keys to be invalidated together
  • Pattern-based eviction
  • Context-aware invalidation
  • Cross-cuting eviction rules
  • Decoupling eviction logic from business services

That’s where @SuperCacheEvict comes in.


🧠 What is @SuperCacheEvict?

@SuperCacheEvict is a custom annotation designed to:

  • Centralize eviction rules
  • Abstract complex invalidation logic
  • Allow advanced key strategies
  • Enable AOP-driven eviction behavior
  • Improve maintainability in microservice environments

Instead of scattering eviction logic across multiple services using @CacheEvict, this annotation acts as a single, expressive eviction entry point.


🏗 Architecture Overview

The POC leverages:

  • Spring Cache Abstraction
  • Redis as a distributed cache
  • Spring AOP to intercept @SuperCacheEvict
  • Actuator + Micrometer for observability

Flow:

  1. A method is annotated with @SuperCacheEvict
  2. A custom AOP aspect intercepts execution
  3. Eviction rules are resolved
  4. Matching Redis keys are invalidated
  5. Metrics can be recorded for observability

🎯 Why Not Just Use @CacheEvict?

@CacheEvict is limited when:

  • You need pattern-based eviction
  • Cache keys are dynamically composed
  • Multiple caches must be invalidated conditionally
  • Eviction logic must evolve independently of business code
  • You want a reusable eviction abstraction across services

@SuperCacheEvict is designed to solve these architectural limitations.


🧪 What This POC Demonstrates

  • Custom annotation design
  • AOP-based cross-cutting eviction logic
  • Advanced Redis key management
  • Distributed cache invalidation strategies
  • Extensible eviction rule modeling
  • Observability of cache operations

🏗 Tech Stack

  • Spring Boot
  • Spring Web
  • Spring Data Redis
  • Spring Cache
  • Spring AOP
  • Spring Boot Actuator
  • Micrometer + Prometheus
  • Redis

📦 Running the Project

1️⃣ Start Redis

docker run -p 6379:6379 redis

2️⃣ Configure Application

spring.redis.host=localhost
spring.redis.port=6379

3️⃣ Run the Application

mvn spring-boot:run

🧠 Architectural Value

This repository is especially useful for backend engineers working with:

  • High-scale systems
  • Event-driven architectures
  • Distributed microservices
  • Complex domain models (DDD)
  • Consistency-sensitive applications (finance, payments, marketplaces)

Correct cache invalidation is one of the hardest problems in distributed systems.

@SuperCacheEvict is an experiment in making that problem more explicit, maintainable, and extensible.


🚧 Future Improvements

  • Rule DSL for eviction policies
  • Support for multi-node cache invalidation
  • Event-driven eviction integration
  • Integration testing scenarios
  • Performance benchmarking

🤝 Contributions

Contributions are welcome.

If you’re interested in distributed caching strategies or advanced eviction patterns, feel free to open an issue or submit a pull request.

About

A Spring Boot proof of concept (POC) focused on advanced distributed cache eviction strategies using Redis, centered around a custom annotation:

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages