Comprehensive developer toolkit providing reusable skills for Java/Spring Boot, TypeScript/NestJS/React/Next.js, Python, PHP, AWS CloudFormation, AI/RAG, DevOps, and more.
82
82%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Risky
Do not use without reviewing
Spring Boot ships with a cache abstraction that wraps expensive service calls behind annotation-driven caches. This abstraction supports multiple cache providers (ConcurrentMap, Caffeine, Redis, Ehcache, JCache) without changing business code. The skill provides a concise workflow for enabling caching, managing cache lifecycles, and validating behavior in Spring Boot 3.5+ services.
@Cacheable, @CachePut, or @CacheEvict to Spring Boot service methods.Use trigger phrases such as "implement service caching", "configure CaffeineCacheManager", "evict caches on update", or "test Spring cache behavior" to load this skill.
Follow these steps to implement caching in Spring Boot applications:
Include spring-boot-starter-cache and your preferred cache provider (Caffeine, Redis, Ehcache) in the project dependencies.
Add @EnableCaching to a @Configuration class and declare CacheManager bean(s) for your cache providers.
Configure cache names, TTL settings, and capacity limits in application.yml or via CacheManager customizer beans.
Apply @Cacheable for read operations, @CachePut for updates, and @CacheEvict for invalidation. Use @CacheConfig to define default cache names at class level.
Use SpEL expressions to define cache keys (key = "#user.id"), conditions (condition = "#price > 0"), and unless clauses (unless = "#result == null").
Create scheduled jobs or use @CacheEvict with allEntries=true to periodically clear time-sensitive caches.
Enable Actuator cache endpoint to observe hit/miss ratios. Consider Micrometer metrics for production observability.
spring-boot-starter-cache; add provider-specific starters as
needed (spring-boot-starter-data-redis, caffeine, ehcache, etc.).Add dependencies
<!-- Maven -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency> <!-- Optional: Caffeine -->
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>implementation "org.springframework.boot:spring-boot-starter-cache"
implementation "com.github.ben-manes.caffeine:caffeine"Enable caching
@Configuration
@EnableCaching
class CacheConfig {
@Bean
CacheManager cacheManager() {
return new CaffeineCacheManager("users", "orders");
}
}Annotate service methods
@Service
@CacheConfig(cacheNames = "users")
class UserService {
@Cacheable(key = "#id", unless = "#result == null")
User findUser(Long id) { ... }
@CachePut(key = "#user.id")
User refreshUser(User user) { ... }
@CacheEvict(key = "#id", beforeInvocation = false)
void deleteUser(Long id) { ... }
}Verify behavior
cache endpoint (if enabled) for hit/miss counters.@Cacheable.@CachePut on write paths that must refresh cache entries.@CacheEvict (allEntries = true when invalidating derived caches).@Caching to keep multi-cache updates consistent.key = "#user.id").condition = "#price > 0" for selective caching.unless = "#result == null".sync = true when needed.spring.cache.caffeine.spec=maximumSize=500,expireAfterWrite=10mspring.cache.redis.time-to-live=600000ttl and heap/off-heap resources.spring.cache.cache-names=users,orders,catalog.CacheManagementService with
programmatic cacheManager.getCache(name) access.@Scheduled.cache endpoint and Micrometer meters to track hit ratio,
eviction count, and size.sync = true scenarios).@CacheResult, @CacheRemove). Avoid mixing with Spring annotations
on the same method.Mono, Flux) or CompletableFuture values.
Spring stores resolved values and resubscribes on hits; consider TTL alignment
with publisher semantics.CacheControl when exposing cached responses
via REST.Input:
// First call - cache miss, method executes
User user1 = userService.findUser(1L);
// Second call - cache hit, method skipped
User user2 = userService.findUser(1L);Output:
// First call logs:
Hibernate: select u1_0.id,u1_0.name from users u1_0 where u1_0.id=?
// Second call: No SQL executed (served from cache)Input:
@Cacheable(value = "products", key = "#id", condition = "#price > 100")
public Product getProduct(Long id, BigDecimal price) {
return productRepository.findById(id);
}
// Only expensive products are cached
getProduct(1L, new BigDecimal("50.00")); // Not cached
getProduct(2L, new BigDecimal("150.00")); // CachedOutput:
Cache 'products' contents after operations:
{2=Product(id=2, price=150.00)}Input:
@CacheEvict(value = "users", key = "#id")
public void deleteUser(Long id) {
userRepository.deleteById(id);
}
deleteUser(1L);Output:
Cache 'users' entry for key '1' removedreferences/cache-examples.md for
progressive scenarios (basic product cache, conditional caching, multilevel
eviction, Redis integration).references/cache-core-reference.md
for annotation matrices, configuration tables, and property samples.references/spring-framework-cache-docs.md:
curated excerpts from the Spring Framework Reference Guide (official).references/spring-cache-doc-snippet.md:
narrative overview extracted 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.plugins
developer-kit-ai
skills
chunking-strategy
prompt-engineering
developer-kit-aws
skills
aws
aws-cli-beast
aws-cost-optimization
aws-drawio-architecture-diagrams
aws-sam-bootstrap
aws-cloudformation
aws-cloudformation-auto-scaling
references
aws-cloudformation-bedrock
references
aws-cloudformation-cloudfront
references
aws-cloudformation-cloudwatch
references
aws-cloudformation-dynamodb
references
aws-cloudformation-ec2
aws-cloudformation-ecs
references
aws-cloudformation-elasticache
aws-cloudformation-iam
references
aws-cloudformation-lambda
references
aws-cloudformation-rds
aws-cloudformation-s3
references
aws-cloudformation-security
references
aws-cloudformation-task-ecs-deploy-gh
aws-cloudformation-vpc
developer-kit-core
skills
developer-kit-java
skills
aws-lambda-java-integration
aws-rds-spring-boot-integration
aws-sdk-java-v2-bedrock
aws-sdk-java-v2-core
aws-sdk-java-v2-dynamodb
aws-sdk-java-v2-kms
aws-sdk-java-v2-lambda
aws-sdk-java-v2-messaging
aws-sdk-java-v2-rds
aws-sdk-java-v2-s3
aws-sdk-java-v2-secrets-manager
graalvm-native-image
langchain4j
langchain4j-mcp-server-patterns
langchain4j-ai-services-patterns
references
langchain4j-mcp-server-patterns
references
langchain4j-rag-implementation-patterns
references
langchain4j-spring-boot-integration
langchain4j-testing-strategies
langchain4j-tool-function-calling-patterns
langchain4j-vector-stores-configuration
references
qdrant
references
spring-ai-mcp-server-patterns
references
spring-boot-actuator
spring-boot-cache
spring-boot-crud-patterns
spring-boot-dependency-injection
spring-boot-event-driven-patterns
spring-boot-openapi-documentation
spring-boot-project-creator
spring-boot-resilience4j
spring-boot-rest-api-standards
spring-boot-saga-pattern
spring-boot-security-jwt
assets
references
scripts
spring-boot-test-patterns
spring-data-jpa
references
spring-data-neo4j
references
unit-test-application-events
unit-test-bean-validation
unit-test-boundary-conditions
unit-test-caching
unit-test-config-properties
unit-test-controller-layer
unit-test-exception-handler
unit-test-json-serialization
unit-test-mapper-converter
unit-test-parameterized
unit-test-scheduled-async
unit-test-service-layer
unit-test-utility-methods
unit-test-wiremock-rest-api
developer-kit-php
skills
aws-lambda-php-integration
developer-kit-python
skills
aws-lambda-python-integration
developer-kit-tools
developer-kit-typescript
skills
aws-lambda-typescript-integration
better-auth
drizzle-orm-patterns
dynamodb-toolbox-patterns
references
nestjs
nestjs-best-practices
nestjs-code-review
nestjs-drizzle-crud-generator
scripts
nextjs-app-router
nextjs-authentication
nextjs-code-review
nextjs-data-fetching
references
nextjs-deployment
nextjs-performance
nx-monorepo
react-code-review
react-patterns
references
shadcn-ui
tailwind-css-patterns
references
tailwind-design-system
references
turborepo-monorepo
typescript-docs
typescript-security-review
zod-validation-utilities