Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
giuseppe-trisciuoglio avatar

Spring Boot Cache

  • 1.8k installs
  • 318 repo stars
  • Updated June 22, 2026
  • giuseppe-trisciuoglio/developer-kit

Provides patterns for implementing Spring Boot caching: configures Redis/Caffeine/EhCache providers with TTL and eviction policies, applies @Cacheable/@CacheEvict/@CachePut annotations, validates cach

About

The spring boot cache skill 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. Documentation covers workflows, commands, and guardrails agents should follow when users invoke this capability. Key documented areas include Add `@Cacheable`, `@CachePut`, or `@CacheEvict` to service methods.; Configure Caffeine, Redis, or Ehcache with TTL and capacity policies.; Implement eviction strategies for stale data.; Diagnose cache misses or invalidation issues. Reference commands include @Service; @CacheConfig(cacheNames = "users"). Use when developers or agents need structured guidance for spring boot cache tasks with evidence grounded in the bundled SKILL.md rather than generic advice. Add `@Cacheable`, `@CachePut`, or `@CacheEvict` to service methods. Configure Caffeine, Redis, or Ehcache with TTL and capacity policies. Implement eviction strategies for stale data.

  • Add `@Cacheable`, `@CachePut`, or `@CacheEvict` to 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.

Spring Boot Cache by the numbers

  • 1,819 all-time installs (skills.sh)
  • +124 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #265 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

spring-boot-cache capabilities & compatibility

Capabilities
add `@cacheable`, `@cacheput`, or `@cacheevict` · configure caffeine, redis, or ehcache with ttl a · implement eviction strategies for stale data. · diagnose cache misses or invalidation issues. · expose hit/miss metrics via actuator or micromet
Use cases
planning
From the docs

What spring-boot-cache says it does

Add `@Cacheable`, `@CachePut`, or `@CacheEvict` to service methods.
SKILL.md
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill spring-boot-cache

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.8k
repo stars318
Security audit3 / 3 scanners passed
Last updatedJune 22, 2026
Repositorygiuseppe-trisciuoglio/developer-kit

How do I handle spring boot cache tasks with agent guidance?

Provides patterns for implementing Spring Boot caching: configures Redis/Caffeine/EhCache providers with TTL and eviction policies, applies @Cacheable/@CacheEvict/@CachePut annotations, validates cach

Who is it for?

Teams needing documented spring boot cache workflows.

Skip if: Generic advice without reading bundled docs.

When should I use this skill?

Provides patterns for implementing Spring Boot caching: configures Redis/Caffeine/EhCache providers with TTL and eviction policies, applies @Cacheable/@CacheEvict/@CachePut annotations, validates cach

What you get

Structured workflow from spring boot cache documentation applied to the user request.

  • CacheManager bean configuration
  • Annotation-based cache definitions

By the numbers

  • Documents 4 common CacheManager implementations: ConcurrentMap, Simple, Caffeine, and EhCache

Files

SKILL.mdMarkdownGitHub ↗

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 @CacheEvict to 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

1. Add dependenciesspring-boot-starter-cache plus a provider:

  • Caffeine: caffeine starter
  • Redis: spring-boot-starter-data-redis
  • Ehcache: ehcache starter

2. Enable caching — annotate a @Configuration class with @EnableCaching and define a CacheManager bean.

3. Annotate methods@Cacheable for reads, @CachePut for writes, @CacheEvict for deletions.

4. Configure TTL/eviction — set spring.cache.caffeine.spec, spring.cache.redis.time-to-live, or spring.cache.ehcache.config.

5. Shape keys — use SpEL in key attributes; guard with condition/unless for selective caching.

6. 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

@Service
@CacheConfig(cacheNames = "users")
class UserService {

    @Cacheable(key = "#id", unless = "#result == null")
    User findUser(Long id) { ... }
}
First call → cache miss, repository invoked
Second call → cache hit, repository skipped

Example 2: Conditional Caching with SpEL

@Cacheable(value = "products", key = "#id", condition = "#price > 100")
public Product getProduct(Long id, BigDecimal price) { ... }

// Only expensive products are cached

Example 3: Cache Eviction

@CacheEvict(value = "users", key = "#id")
public void deleteUser(Long id) { ... }

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) or CompletableFuture values.
  • Apply HTTP CacheControl headers when exposing cached responses via REST.
  • Schedule periodic eviction with @Scheduled for time-bound caches.
  • Create a CacheManagementService for programmatic cacheManager.getCache(name).

Troubleshooting

If cache misses persist after adding @Cacheable:

1. Verify @EnableCaching is present on a @Configuration class. 2. Confirm the method is public and called from outside the class (Spring uses proxies; self-invocation bypasses the cache). 3. Validate SpEL key expressions resolve correctly. 4. Confirm the cache manager bean is registered as cacheManager or explicitly referenced via cacheManager = "myCacheManager".

References

  • `references/spring-framework-cache-docs.md`:

curated excerpts from Spring Framework Reference Guide.

  • `references/spring-cache-doc-snippet.md`:

narrative overview from Spring documentation.

  • `references/cache-core-reference.md`:

annotation parameters, dependency matrices, property catalogs.

  • `references/cache-examples.md`:

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

  • `../spring-boot-rest-api-standards`
  • `../spring-boot-test-patterns`
  • `../unit-test-caching`

Related skills

Forks & variants (1)

Spring Boot Cache has 1 known copy in the catalog totaling 21 installs. They canonicalize to this original listing.

How it compares

Use this reference skill for Spring-native cache abstraction choices instead of generic caching tutorials that skip CacheManager tradeoffs.

FAQ

What does spring boot cache do?

Provides patterns for implementing Spring Boot caching: configures Redis/Caffeine/EhCache providers with TTL and eviction policies, applies @Cacheable/@CacheEvict/@CachePut annotations, validates cach

When should I invoke spring boot cache?

Provides patterns for implementing Spring Boot caching: configures Redis/Caffeine/EhCache providers with TTL and eviction policies, applies @Cacheable/@CacheEvict/@CachePut annotations, validates cach

What are key capabilities?

Add `@Cacheable`, `@CachePut`, or `@CacheEvict` to service methods.

Is Spring Boot Cache safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.