AgentSkillsCN

caching

为Wicked Garden插件打造统一的缓存基础设施,支持命名空间隔离、TTL管理以及基于文件的缓存失效机制。当插件需要在会话间缓存数据、存储分析结果,或实施缓存失效策略时,可选用此方案。

SKILL.md
--- frontmatter
name: caching
description: |
  Unified caching infrastructure for Wicked Garden plugins with namespace isolation,
  TTL support, and file-based invalidation. Use when plugins need to cache data between
  sessions, store analysis results, or implement cache invalidation strategies.
triggers:
  - "cache data"
  - "store between sessions"
  - "cache invalidation"
  - "TTL expiration"
  - "wicked-cache"
  - "namespace cache"

Caching Infrastructure

Unified cache API for Wicked Garden plugins.

Quick Start

python
import sys
from pathlib import Path

# Add wicked-cache to path
cache_path = Path.home() / ".claude" / "plugins" / "wicked-cache" / "scripts"
sys.path.insert(0, str(cache_path))

from cache import namespace

# Get a namespaced cache client
cache = namespace("my-plugin")

# Store and retrieve
cache.set("key", {"data": "value"})
data = cache.get("key")  # Returns None on miss

Core API

MethodPurpose
namespace(name)Get scoped cache client
cache.set(key, value, ...)Store value
cache.get(key)Retrieve (None on miss)
cache.invalidate(key)Explicitly invalidate
cache.clear()Clear namespace
cache.stats()Get statistics

Invalidation Modes

ModeUse CaseExample
FileSchema/analysis cachingcache.set(key, val, source_file="./data.csv")
TTLAPI responsescache.set(key, val, options={"mode": "ttl", "ttl_seconds": 300})
ManualConfigurationcache.set(key, val, options={"mode": "manual"})

Workflow Guides

For specific use cases, read the appropriate guide from references/:

TaskGuide
Caching file schemas/analysisreferences/schema-caching.md
Caching API responsesreferences/api-response-caching.md
Choosing invalidation strategyreferences/invalidation-strategies.md

Commands

bash
/wicked-cache:setup              # Initialize
/wicked-cache:cache list         # List keys
/wicked-cache:cache stats        # Statistics
/wicked-cache:cache clear <ns>   # Clear namespace

Security

  • Namespace validation prevents path traversal
  • Key validation: alphanumeric + hyphens + colons
  • Don't cache sensitive/PII data