Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计未展示

cache_patterns缓存模式

Agent Skill

cache_patterns 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

372

周安装

16

GitHub Stars

42

下载量

131
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:cache_patterns(缓存模式)
来源仓库:https://github.com/vuralserhat86/antigravity-agentic-skills
仓库路径:skills/cache_patterns
安装命令:
npx skills add https://github.com/vuralserhat86/antigravity-agentic-skills --skill cache_patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/vuralserhat86/antigravity-agentic-skills --skill cache_patterns

简介

cache_patterns 提供 Spring Boot 缓存抽象层的使用指南,支持多种后端存储。

  • 适用于 ConcurrentMap、Caffeine、Redis 等缓存提供者的配置与管理。
  • 可诊断缓存失效与命中率问题,优化服务调用性能。
  • 使用前需确认 Spring Boot 版本不低于 3.5 并启用缓存注解。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

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 <!-- 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"
  2. Enable caching @Configuration @EnableCaching class CacheConfig {@Bean CacheManager cacheManager() {return new CaffeineCacheManager("users", "orders");}}
  3. 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) {...}}
  4. 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

Kaynak: Spring Boot Caching Guide & Caffeine Cache Best Practices

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

References

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

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

31.83%
按下载量换算42

Antigravity

25.22%
按下载量换算33

trae

16.67%
按下载量换算22

OpenCode

13.34%
按下载量换算17

Gemini CLI

8.1%
按下载量换算11

Codex

3.28%
按下载量换算4

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills