vuralserhat86/antigravity-agentic-skills/cache-patterns

Claude Code and agent skill by vuralserhat86/antigravity-agentic-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Instruction set for enabling and operating the Spring Cache abstraction in Spring Boot when implementing application-level caching for performance-sensitive workloads.

Install

npx vskill@latest install vuralserhat86/antigravity-agentic-skills/cache-patterns

SKILL.md

The same SKILL.md was published earlier as vuralserhat86/antigravity-agentic-skills/cache-patterns.

Spring Boot Cache Abstraction

Overview

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.

When to Use

  • Add @Cacheable, @CachePut, or @CacheEvict to Spring Boot service methods.
  • Configure Caffeine, Redis, or JCache cache managers for Spring Boot.
  • Diagnose cache invalidation, eviction scheduling, or cache key issues.
  • Expose cache management endpoints or scheduled eviction routines.

Use trigger phrases such as "implement service caching", "configure CaffeineCacheManager", "evict caches on update", or "test Spring cache behavior" to load this skill.

Prerequisites

  • Java 17+ project based on Spring Boot 3.5.x (records encouraged for DTOs).
  • Dependency spring-boot-starter-cache; add provider-specific starters as

needed (spring-boot-starter-data-redis, caffeine, ehcache, etc.).

  • Constructor-injected services that expose deterministic method signatures.
  • Observability stack (Actuator, Micrometer) when operating caches in

production.

Quick Start

  1. Add dependencies

``xml <!-- 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> ``

``gradle implementation "org.springframework.boot:spring-boot-starter-cache" implementation "com.github.ben-manes.caffeine:caffeine" ``

  1. Enable caching

``java @Configuration @EnableCaching class CacheConfig { @Bean CacheManager cacheManager() { return new CaffeineCacheManager("users", "orders"); } } ``

  1. Annotate service methods

```java @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) { ... } } ```

  1. Verify behavior
  • Run focused unit tests that call cached methods twice and assert repository

invocations.

  • Inspect Actuator cache endpoint (if enabled) for hit/miss counters.

🔄 Workflow

Aşama 1: Strategy & Provider Selection
  • [ ] Identifying Hot Paths: En çok beklenen ve nadir değişen veri okuma (I/O) noktalarını belirle.
  • [ ] Provider Selection: Bellek içi (Caffeine) veya dağıtık (Redis) cache seçimine karar ver.
  • [ ] Key Design: SpEL kullanarak benzersiz ve tahmin edilebilir cache key strategy'si oluştur.
Aşama 2: Annotation Implementation
  • [ ] @Cacheable: Veriyi cache'e yaz we sonraki çağrılarda oradan oku.
  • [ ] @CachePut: Veri güncellendiğinde cache'i de yenile.
  • [ ] @CacheEvict: Silme işlemlerinde veya belirli periyotlarda cache'i temizle (allEntries=true opsiyonunu değerlendir).
Aşama 3: LifeCycle & Monitoring
  • [ ] TTL/Eviction: Veri tazeliği (TTL) ve temizleme (Eviction) politikalarını (LRU/LFU) konfigüre et.
  • [ ] Actuator Audit: cache endpoint'i üzerinden hit/miss oranlarını izle.
  • [ ] Integration Testing: @SpringBootTest ile cache izolasyonunu ve tutarlılığını test et.
Kontrol Noktaları
AşamaDoğrulama
1Transactional işlemler sırasında cache tutarlılığı (Data drift) bozuluyor mu?
2"Cache-aside" veya "ReadOnly" stratejisi doğru uygulandı mı?
3Çoklu instance yapısında "Cache Stampede" riski önlendi mi?

Cache Patterns v2.0 - With Workflow

Advanced Options

  • Integrate JCache annotations when interoperating with providers that favor

JSR-107 (@CacheResult, @CacheRemove). Avoid mixing with Spring annotations on the same method.

  • Cache reactive return types (Mono, Flux) or CompletableFuture values.

Spring stores resolved values and resubscribes on hits; consider TTL alignment with publisher semantics.

  • Apply HTTP caching headers using CacheControl when exposing cached responses

via REST.

Examples

progressive scenarios (basic product cache, conditional caching, multilevel eviction, Redis integration).

for annotation matrices, configuration tables, and property samples.

References

curated excerpts from the Spring Framework Reference Guide (official).

narrative overview extracted from Spring documentation.

annotation parameters, dependency matrices, property catalogs.

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 to avoid noise; push metrics via Micrometer.
  • Tune TTLs based on data staleness tolerance; document rationale in code.
  • Guard caches that store 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.

  • Ensure multi-level caches (e.g. Caffeine + Redis) maintain consistency; prefer

publish/subscribe invalidation channels.

  • Validate serialization compatibility when caching across service instances.
  • Monitor memory footprint to prevent OOM when using in-memory stores.

Related Skills

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationWarning, 73 of 100Marginal. 1 run. Evaluated 8 months ago.

Source

Popularity

Repository stars
42
Repository forks
12
7-day trend score
19

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 1 Apr 2026, 8 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/vuralserhat86/antigravity-agentic-skills/cache-patterns/badge)](https://verified-skill.com/skills/vuralserhat86/antigravity-agentic-skills/cache-patterns)

Something wrong with this skill or its page? Tell us.