giuseppe-trisciuoglio/developer-kit/spring-boot-cache
- community
Checking that the SKILL.md file is still in the repository.
Provides patterns for implementing Spring Boot caching: configures Redis/Caffeine/EhCache providers with TTL and eviction policies, applies @Cacheable/@CacheEvict/@CachePut annotations, validates cache hit/miss behavior, and exposes metrics via Actuator. Use when adding caching to Spring Boot services, configuring cache expiration, evicting stale data, or diagnosing cache misses.
Install
npx vskill@latest install giuseppe-trisciuoglio/developer-kit/spring-boot-cacheSKILL.md
Spring Boot Cache Abstraction
Overview
6-step workflow for enabling cache abstraction, configuring providers (Caffeine, Redis, Ehcache), annotating service methods, and validating behavior in Spring Boot 3.5+ applications. Apply @Cacheable for reads, @CachePut for writes, @CacheEvict for deletions. Configure TTL/eviction policies and expose metrics via Actuator.
When to Use
- Add
@Cacheable,@CachePut, or@CacheEvictto service methods. - Configure Caffeine, Redis, or Ehcache with TTL and capacity policies.
- Implement eviction strategies for stale data.
- Diagnose cache misses or invalidation issues.
- Expose hit/miss metrics via Actuator or Micrometer.
Instructions
- Add dependencies —
spring-boot-starter-cacheplus a provider:
- Caffeine:
caffeinestarter - Redis:
spring-boot-starter-data-redis - Ehcache:
ehcachestarter
- Enable caching — annotate a
@Configurationclass with@EnableCaching
and define a CacheManager bean.
- Annotate methods —
@Cacheablefor reads,@CachePutfor writes,
@CacheEvict for deletions.
- Configure TTL/eviction — set
spring.cache.caffeine.spec,
spring.cache.redis.time-to-live, or spring.cache.ehcache.config.
- Shape keys — use SpEL in
keyattributes; guard with
condition/unless for selective caching.
- Validate setup — run integration test to confirm cache hit on second
call; check GET /actuator/caches to verify cache manager registration; query GET /actuator/metrics/cache.gets for hit/miss ratios.
Examples
Example 1: Basic @Cacheable Usage
Example 2: Conditional Caching with SpEL
Example 3: Cache Eviction
For progressive scenarios (basic product cache, multilevel eviction, Redis integration), load `references/cache-examples.md`.
Advanced Options
- Use JCache annotations (
@CacheResult,@CacheRemove) for providers favoring
JSR-107 interoperability; avoid mixing with Spring annotations on the same method.
- Cache reactive return types (
Mono,Flux) orCompletableFuturevalues. - Apply HTTP
CacheControlheaders when exposing cached responses via REST. - Schedule periodic eviction with
@Scheduledfor time-bound caches. - Create a
CacheManagementServicefor programmaticcacheManager.getCache(name).
Troubleshooting
If cache misses persist after adding @Cacheable:
- Verify
@EnableCachingis present on a@Configurationclass. - Confirm the method is public and called from outside the class (Spring uses
proxies; self-invocation bypasses the cache).
- Validate SpEL key expressions resolve correctly.
- Confirm the cache manager bean is registered as
cacheManageror explicitly
referenced via cacheManager = "myCacheManager".
References
curated excerpts from Spring Framework Reference Guide.
narrative overview from Spring documentation.
annotation parameters, dependency matrices, property catalogs.
end-to-end examples with tests.
Best Practices
- Prefer constructor injection and immutable DTOs for cache entries.
- Separate cache names per aggregate (
users,orders) to simplify eviction. - Log cache hits/misses only at debug; push metrics via Micrometer.
- Tune TTLs based on data staleness tolerance; document rationale in code.
- Guard caches storing PII or credentials with encryption or avoid caching.
- Align cache eviction with transactional boundaries to prevent dirty reads.
Constraints and Warnings
- Avoid caching mutable entities that depend on open persistence contexts.
- Do not mix Spring cache annotations with JCache annotations on the same method.
- Validate serialization compatibility when caching across service instances.
- Monitor memory footprint to prevent OOM with in-memory stores.
- Caffeine + Redis multi-level caches require publish/subscribe invalidation channels.
Related Skills
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/developer-kit-java/skills/spring-boot-cache/SKILL.md
Popularity
- Repository stars
- 249
- Repository forks
- 27
- 7-day trend score
- 28
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 20 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/giuseppe-trisciuoglio/developer-kit/spring-boot-cache)