Loading...
Loading...
Instruction set for enabling and operating the Spring Cache abstraction in Spring Boot when implementing application-level caching for performance-sensitive workloads.
npx skill4agent add giuseppe-trisciuoglio/developer-kit spring-boot-cache@Cacheable@CachePut@CacheEvictspring-boot-starter-cachespring-boot-starter-data-rediscaffeineehcache<!-- 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"@Configuration
@EnableCaching
class CacheConfig {
@Bean
CacheManager cacheManager() {
return new CaffeineCacheManager("users", "orders");
}
}@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) { ... }
}cache@Cacheable@CachePut@CacheEvictallEntries = true@Cachingkey = "#user.id"condition = "#price > 0"unless = "#result == null"sync = truespring.cache.caffeine.spec=maximumSize=500,expireAfterWrite=10mspring.cache.redis.time-to-live=600000ttlspring.cache.cache-names=users,orders,catalogCacheManagementServicecacheManager.getCache(name)@Scheduledcachesync = true@CacheResult@CacheRemoveMonoFluxCompletableFutureCacheControlreferences/cache-examples.mdreferences/cache-core-reference.mdreferences/spring-framework-cache-docs.mdreferences/spring-cache-doc-snippet.mdreferences/cache-core-reference.mdreferences/cache-examples.mdusersordersskills/spring-boot/spring-boot-rest-api-standardsskills/spring-boot/spring-boot-test-patternsskills/junit-test/unit-test-caching