A Spring Boot proof of concept (POC) focused on advanced distributed cache eviction strategies using Redis, centered around a custom annotation:
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.
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.
@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.
The POC leverages:
- Spring Cache Abstraction
- Redis as a distributed cache
- Spring AOP to intercept
@SuperCacheEvict - Actuator + Micrometer for observability
Flow:
- A method is annotated with
@SuperCacheEvict - A custom AOP aspect intercepts execution
- Eviction rules are resolved
- Matching Redis keys are invalidated
- Metrics can be recorded for observability
@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.
- 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
- Spring Boot
- Spring Web
- Spring Data Redis
- Spring Cache
- Spring AOP
- Spring Boot Actuator
- Micrometer + Prometheus
- Redis
docker run -p 6379:6379 redisspring.redis.host=localhost
spring.redis.port=6379mvn spring-boot:runThis 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.
- Rule DSL for eviction policies
- Support for multi-node cache invalidation
- Event-driven eviction integration
- Integration testing scenarios
- Performance benchmarking
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.