/giuseppe-trisciuoglio:spring-boot-cachefrom giuseppe-trisciuoglio
Provides patterns for enabling and operating the Spring Cache abstraction in Spring Boot. Use when implementing application-level caching for performance-sensitive workloads.
Ships in giuseppe-trisciuoglio. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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")); // Cached
Output:
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' removed
references/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.What SKILL.md sets; muted values are Claude Code's defaults
95 skills in this plugin
/aws-cloudformation-auto-scalingaws-rds-spring-boot-integrationProvides patterns to configure AWS RDS (Aurora, MySQL, PostgreSQL) with Spring Boot applications. Use when setting up datasources, connection pooling, security, and production-ready database configuration./aws-cloudformation-bedrockaws-sdk-java-v2-bedrockProvides Amazon Bedrock patterns using AWS SDK for Java 2.x. Use when working with foundation models (listing, invoking), text generation, image generation, embeddings, streaming responses, or integrating generative AI with Spring Boot applications./aws-cloudformation-cloudfrontnpx claudepluginhub ulpi-io/plugin-marketplace --plugin giuseppe-trisciuoglioOther plugins' skills for the same job