mit einem Klick
spring-boot-cache
Use when adding caching to Spring Boot 4 services, configuring cache providers and TTL policies, invalidating stale data, or diagnosing cache hit and miss behavior.
Menü
Use when adding caching to Spring Boot 4 services, configuring cache providers and TTL policies, invalidating stale data, or diagnosing cache hit and miss behavior.
Use when configuring Spring Boot Actuator for production-grade monitoring, health probes, secured management endpoints, readiness/liveness checks, and Micrometer metrics in Spring Boot 4 applications.
Use when building Model Context Protocol servers in Spring Boot with Spring AI, exposing tools or resources, configuring transports, or integrating AI tool-calling workflows.
Use when integrating Neo4j into a Spring Boot 4 backend with graph models, Cypher queries, reactive repositories, relationship mapping, or graph-focused testing patterns.
Use when implementing event-driven or message-based integration in Spring Boot 4, publishing domain events, coordinating Kafka or broker messaging, or applying outbox and idempotency patterns for reliable delivery.
Use when documenting reactive Spring Boot 4 HTTP APIs with SpringDoc OpenAPI, configuring Swagger UI, annotating endpoints, documenting security schemes, or defining request and response schemas.
Use when implementing reactive fault-tolerance patterns in Spring Boot 4 with native Spring Framework 7 resilience features or Resilience4j, including retries, concurrency limiting, circuit breakers, rate limiting, timeouts, and fallbacks for downstream calls.
| name | spring-boot-cache |
| description | Use when adding caching to Spring Boot 4 services, configuring cache providers and TTL policies, invalidating stale data, or diagnosing cache hit and miss behavior. |
| allowed-tools | Read, Write, Bash |
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.
@Cacheable, @CachePut, or @CacheEvict to service methods.Add dependencies — spring-boot-starter-cache plus a provider:
caffeine starterspring-boot-starter-data-redisehcache starterEnable caching — annotate a @Configuration class with @EnableCaching
and define a CacheManager bean.
Annotate methods — @Cacheable for reads, @CachePut for 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 key attributes; 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.
@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
@Cacheable(value = "products", key = "#id", condition = "#price > 100")
public Product getProduct(Long id, BigDecimal price) { ... }
// Only expensive products are cached
@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.
@CacheResult, @CacheRemove) for providers favoring
JSR-107 interoperability; avoid mixing with Spring annotations on the same method.Mono, Flux) or CompletableFuture values.CacheControl headers when exposing cached responses via REST.@Scheduled for time-bound caches.CacheManagementService for programmatic cacheManager.getCache(name).If cache misses persist after adding @Cacheable:
@EnableCaching is present on a @Configuration class.cacheManager or explicitly
referenced via cacheManager = "myCacheManager".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.users, orders) to simplify eviction.../SKILL.md — Core reactive API and infrastructure rulesspring-boot/testing-integrations — Cache integration and verification patternsspring-boot/testing-core — Focused unit tests around cache decisions and collaborators