Agent skill

Cache Framework

by Rain-kl in Rain-kl/OpenFlare

Wavelet 项目专用:当新增或修改业务缓存(RAM/Redis/DB 三层读路径)、缓存失效、多节点 pub/sub 同步、或评估高频读是否应接入缓存时必须使用。本技能说明系统标准缓存框架、参考实现、禁止写法与分布式一致性要求。

Apache-2.0Auto-check passedDatabases

Install Cache Framework

skills CLI
$ npx skills add Rain-kl/OpenFlare --skill cache-framework -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Rain-kl/OpenFlare cache-framework --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Rain-kl/OpenFlare.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/cache-framework .claude/skills/cache-framework && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cache-framework
GitHub stars
288
Token cost
~1.7k tokens
SKILL.md length
346 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
Apache-2.0

At a glance

Wavelet 项目专用:当新增或修改业务缓存(RAM/Redis/DB 三层读路径)、缓存失效、多节点 pub/sub 同步、或评估高频读是否应接入缓存时必须使用。本技能说明系统标准缓存框架、参考实现、禁止写法与分布式一致性要求。

  • Works in 3 steps: 本机 RAM — thingRAM.Invalidate(key) 或… → Redis — Del / HDel 对应 key → pub/sub 广播 — 通知其他节点清除 RAM(Redis 已由写节点清掉)
  • Tasks that involve Event-driven systems
  • SKILL.md covers 关联 Skill, 标准模式(金标准), 现有实现速查 and 新增缓存工作流, plus 5 more sections
  • Calls go and make

What it does

Cache Framework is an agent skill from Rain-kl/OpenFlare. Wavelet 项目专用:当新增或修改业务缓存(RAM/Redis/DB 三层读路径)、缓存失效、多节点 pub/sub 同步、或评估高频读是否应接入缓存时必须使用。本技能说明系统标准缓存框架、参考实现、禁止写法与分布式一致性要求。

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Event-driven systems. It works with Redis and Cloudflare. The repository describes itself as: OpenFlare is an open-source CDN orchestration and edge security platform. It supports reverse proxy, centralized configuration synchronization, in-network tunneling (Tunnels)… The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Event-driven systems

Example prompts

  • “/cache-framework”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. 本机 RAM — thingRAM.Invalidate(key) 或 InvalidateAll()
  2. Redis — Del / HDel 对应 key
  3. pub/sub 广播 — 通知其他节点清除 RAM(Redis 已由写节点清掉)

What it can do on your machine

Read from SKILL.md and the folder at commit 7c2304d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • go
    • make

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cache Framework loads about 1.7k tokens when it runs. Until then it costs about 33 tokens; SKILL.md has 346 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~33
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Rain-kl/OpenFlare at commit 7c2304d, republished under its Apache-2.0 licence (© Rain-kl). 346 words, ~1,726 tokens.

Download SKILL.mdSave it as .claude/skills/cache-framework/SKILL.md (or your agent's skills folder).
name
cache-framework
description
Wavelet 项目专用:当新增或修改业务缓存(RAM/Redis/DB 三层读路径)、缓存失效、多节点 pub/sub 同步、或评估高频读是否应接入缓存时必须使用。本技能说明系统标准缓存框架、参考实现、禁止写法与分布式一致性要求。

系统三层缓存框架

开始前阅读根目录 AGENTS.md(含 Skill 关联索引)。Wavelet 标准读路径为 本地 RAM → Redis → PostgreSQL(由快到慢),不是 DB 优先。

详细性能背景见 docs/PERFORMANCE.md。

关联 Skill

关联何时一并阅读
database-migration缓存对象对应新表/列/索引,或 seed 变更
new-setting系统配置类缓存(GetSystemConfigByKey、ListSystemConfigsByKeys)
file-upload上传元数据 upload:meta:{id}、ingest/remove/cleanup 失效钩子
clickhouse-batchwriter分析写入走 batchwriter,不要用本技能模式缓存 CH flush 队列
new-api在 Handler 层接入 GetXxxCached 或评估高频读
new-async-taskWorker/定时任务变更数据后必须 Invalidate*(如 system:cleanup)

标准模式(金标准)

参考:internal/repository/system_config_cache.go + GetSystemConfigByKey / ListSystemConfigsByKeys。

层级技术职责
L1 本地pkg/cache/ram(Otter v2)进程内热数据,最低延迟
L2 共享Redis db.GetJSON / SetJSON / HSetJSON + db.PrefixedKey跨节点共享,带 TTL 或写穿
L3 权威PostgreSQL via db.DB(ctx)唯一数据源
读路径模板
go
func GetThingCached(ctx context.Context, key string) (Thing, error) {
    ensureThingCacheListener() // 订阅 pub/sub,仅 sync.Once

    if v, ok := thingRAM.GetIfPresent(key); ok {
        return cloneThing(v), nil
    }
    if db.Redis != nil {
        var v Thing
        if err := db.GetJSON(ctx, redisKey(key), &v); err == nil {
            thingRAM.Set(key, cloneThing(v))
            return v, nil
        }
    }
    v, err := loadThingFromDB(ctx, key)
    if err != nil {
        return Thing{}, err
    }
    populateThingCache(ctx, v) // 回写 RAM + Redis
    return v, nil
}
写穿(populate)

DB miss 或业务创建成功后,必须回写上层:

go
func populateThingCache(ctx context.Context, v Thing) {
    thingRAM.Set(v.Key, cloneThing(v))
    if db.Redis != nil {
        _ = db.SetJSON(ctx, redisKey(v.Key), v, cacheTTL)
    }
}
失效(Invalidate)— 分布式必做三步

数据变更(Admin 更新、软删除、状态迁移)时:

  1. 本机 RAM — thingRAM.Invalidate(key) 或 InvalidateAll()
  2. Redis — Del / HDel 对应 key
  3. pub/sub 广播 — 通知其他节点清除 RAM(Redis 已由写节点清掉)
go
func InvalidateThingCache(ctx context.Context, key string) error {
    ensureThingCacheListener()
    thingRAM.Invalidate(key)
    if db.Redis != nil {
        if err := db.Redis.Del(ctx, db.PrefixedKey(redisKey(key))).Err(); err != nil {
            return err
        }
        publishThingRAMInvalidation(ctx, key) // 只广播 RAM 失效
    }
    return nil
}
pub/sub 监听模板
go
const thingInvalidationChannel = "domain:thing_invalidation"

func startThingCacheInvalidationListener() {
    if db.Redis == nil {
        return
    }
    go func() {
        pubsub := db.Redis.Subscribe(context.Background(), thingInvalidationChannel)
        defer func() { _ = pubsub.Close() }()
        for msg := range pubsub.Channel() {
            // 解析 payload,Invalidate RAM;勿重复 Del Redis
            thingRAM.Invalidate(parsedKey)
        }
    }()
}
  • 使用 sync.Once 启动监听;ensureListener 必须在 db.Redis == nil 时直接 return,不可消费 Once(否则测试或 Redis 晚初始化时监听器永不启动)。
  • 测试可提供 StopThingCacheListener + 重置 Once(参考 StopUploadMetaCacheListener、StopAuthSourceCacheListener)。
  • 其他节点收到消息后只清 RAM,不再删 Redis。

现有实现速查

域文件L1L2pub/sub
系统配置repository/system_config_cache.gopkg/cache/store❌ 无 Redis 缓存system:config_broadcast (别名 system:config_invalidation) ✅
CAPTCHA 运行时apps/cap/runtime_settings.goatomic.Pointer(借配置 Redis)订阅 system:config_invalidation ✅
上传元数据apps/upload/cache/meta_cache.goOtterRedis JSONupload:meta_invalidation ✅
上传访问白名单apps/upload/cache/access_cache.go进程内 TTL(借配置读路径)upload:file_access_invalidation ✅
Auth Sourcerepository/auth_source_cache.goOtterRedis JSONoauth:auth_source_invalidation ✅
OAuth 用户/Tokenapps/oauth/cache.go自研 mapRedis JSON❌ 无 pub/sub(历史债)
推送渠道repository/push_channel.go无Redis JSON❌ 仅 Redis Del
Storage 驱动internal/infra/objectstore/storage.goRWMutex 快照—storage:config_invalidation ✅

新增缓存工作流

  1. 判定是否需要缓存:高频读、低变更、可容忍短暂 TTL;写路径必须能统一失效。
  2. 选型 L1:优先 pkg/cache/ram.MustNew;禁止自研 map+mutex+TTL,除非有充分理由并文档说明。
  3. 选型 L2:小对象 SetJSON;配置类多条目用 Redis Hash(HSetJSON)。
  4. 定义 Redis key:小写蛇形,带业务前缀(upload:meta:{id});统一 db.PrefixedKey。
  5. 实现 Invalidate + pub/sub:凡多实例部署可读的 RAM 缓存必须有失效广播。
  6. 挂载变更钩子:在所有 DB 变更入口调用 Invalidate(含 Worker/定时任务,不只 HTTP Handler)。
  7. 测试:
    • RAM hit / Redis hit / DB fallback
    • Invalidate 清 L1+L2
    • pub/sub 触发他机 RAM 失效(可用 miniredis Publish 模拟)
    • Reset*RAMCacheForTest 仅清本机 RAM
  8. 运行 go test 相关包 + make code-check。

变更钩子清单(上传元数据示例)

入口动作
ingest.persistUploadRecord 创建成功SetUploadMetaCache
ingest.Remove / RemoveOwnedInvalidateUploadMetaCache
task/cleanup.go 软删除 pending 文件InvalidateUploadMetaCache
直接 repository.SoftDeleteUpload禁止 — 必须走 upload.Remove

禁止写法

go
// ❌ 自研 L1,与 pkg/cache/ram 重复
var mu sync.RWMutex
var items = map[uint64]entry{}

// ❌ 只清本机 RAM + Redis,无 pub/sub(多节点 RAM 脏读)
func Invalidate(ctx context.Context, id uint64) {
    localDelete(id)
    redis.Del(...)
}

// ❌ DB 变更后忘记 Worker 路径
// cleanup 任务删了 upload 行,但未 InvalidateUploadMetaCache

// ❌ 在 Handler 里直接查 DB,绕过已有 GetXxxCached

// ❌ Redis key 不用 PrefixedKey(多环境共 Redis 时冲突)

// ❌ 在 init() 里启动 pub/sub 监听 — 与 bootstrap 规范冲突;用 sync.Once 懒启动

特殊场景

敏感字段(ClientSecret)

模型 json:"-" 时,Redis DTO 用独立 *RedisRecord struct 显式序列化字段(见 auth_source_cache.go)。

批量读配置

批量接口必须与单 key 一致走 Redis(ListSystemConfigsByKeys 在 RAM miss 后逐 key HGetJSON,再 DB IN)。

仅进程内、短 TTL、配置衍生

可用进程内快照 + 订阅上游 pub/sub(access_cache.go、cap/runtime_settings.go),不必强行 Redis L2。

OAuth 用户/Token

沿用 oauth/cache.go;新增逻辑调用 SetCachedUser / SetCachedToken 预热,变更调用 InvalidateCachedUser / InvalidateCachedToken。

验证清单

bash
go test ./internal/repository/... ./internal/apps/upload/cache/...
make code-check
  • L1 使用 pkg/cache/ram(或已文档化的例外)
  • 读路径:RAM → Redis → DB
  • 写穿 populate 在 DB load / 创建成功后
  • Invalidate:RAM + Redis + Publish
  • ensureListener + pub/sub 清他机 RAM
  • 所有变更入口(含 Worker)已挂钩
  • 测试含 Invalidate 与 pub/sub

相关文件

  • L1 引擎:pkg/cache/ram/cache.go
  • DB/Redis 助手:internal/infra/persistence/redis.go(GetJSON, SetJSON, HGetJSON, PrefixedKey)
  • 金标准:internal/repository/system_config_cache.go
  • 上传元数据:internal/apps/upload/cache/meta_cache.go
  • Auth Source:internal/repository/auth_source_cache.go
  • 性能文档:docs/PERFORMANCE.md

© Rain-kl, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/cache-framework of Rain-kl/OpenFlare.

Open the folder on GitHubat commit 7c2304d

Compare with similar skills

Cache Framework next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cache Framework compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cache Framework this skillRain-kl/OpenFlare288—~1.7kAutomated safety check: PassApache-2.0
Flox Environmentsaffaan-m/ECC275k2 repos~3.5kAutomated safety check: NotesMIT
Flox Environmentsaffaan-m/ECC275k—~2.8kAutomated safety check: PassMIT
Redis Patternsaffaan-m/ECC275k—~2.7kAutomated safety check: PassMIT
Infra AuditSethGammon/Citadel922—~2.1kAutomated safety check: NotesMIT
Use Sealoshashgraph-online/awesome-codex-plugins1.2k—~2.2kAutomated safety check: PassApache-2.0

Similar skills

  • Flox Environments

    affaan-m/ECC

    Create reproducible, cross-platform (macOS/Linux) development environments with Flox, a declarative Nix-based environment manager.

    275k GitHub starsUsed in 2 repos~3.5k tokens
    DatabasesAuto-check: notes
  • Flox Environments

    affaan-m/ECC

    Floxで再現可能なクロスプラットフォーム開発環境を作成します — Nixに基づく宣言的な環境マネージャー。次の場合は必ずこのスキルを使用してください: システムレベルの依存関係(コンパイラー、データベース、openssl・libvips・BLAS・LAPACKなどのネイティブライブラリー)を持つプロジェクトを設定する場合…

    275k GitHub stars~2.8k tokensUpdated 3 days ago
    DatabasesAuto-check passed
  • Redis Patterns

    affaan-m/ECC

    Redisデータ構造パターン、キャッシング戦略、分散ロック、レート制限、Pub/Sub、本番アプリケーション用コネクション管理。

    275k GitHub stars~2.7k tokensUpdated 3 days ago
    DatabasesAuto-check passed
  • Infra Audit

    SethGammon/Citadel

    Reads docker-compose, env files, ORM configs, and connection strings to map current infrastructure.

    922 GitHub stars~2.1k tokensUpdated 6 days ago
    DatabasesAuto-check: notes
  • Use Sealos

    hashgraph-online/awesome-codex-plugins

    Deploy and operate apps on Sealos Cloud: sign in to a Sealos account, deploy any project or self-hosted app (from the template store, an official Docker image, or project source code), provision…

    1.2k GitHub stars~2.2k tokensUpdated today
    DatabasesAuto-check passed
  • Redis Patterns

    rohitg00/awesome-claude-code-toolkit

    Redis patterns including caching strategies, pub/sub, streams for event processing, Lua scripts, and data structures

    2.7k GitHub stars~1.2k tokensUpdated 4 mo ago
    DatabasesAuto-check passed

More from Rain-kl/OpenFlare

All 12 skills in this repo
  • Code Review Skill

    Rain-kl/OpenFlare

    Provides comprehensive code review guidance for React 19, Vue 3, Angular 17+, Svelte 5, Rust, TypeScript, Java, PHP, Python, Django, Go, C/.NET, Kotlin, Swift, NestJS, C/C++, and more.

    288 GitHub stars~2.3k tokensUpdated today
    Auto-check: notes
  • Go Logging

    Rain-kl/OpenFlare

    在选择日志方案、配置 slog、编写结构化日志语句或决定日志级别时使用。也适用于设置生产日志、为日志添加请求作用域上下文或从 log 迁移到 slog 的场景,即使用户未明确提及日志。不涵盖错误处理策略(参见 go-error-handling)。

    288 GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • New API

    Rain-kl/OpenFlare

    Wavelet 项目专用:当新增或修改自定义业务 API、新增业务路由、新增 service 层核心逻辑时必须使用。本技能指导包职责划分、推荐文件结构、路由解耦、Swagger 文档生成与质量门禁验证。

    288 GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Clickhouse Batchwriter

    Rain-kl/OpenFlare

    Wavelet 项目专用:当新增或修改 ClickHouse 批量写入、接入 internal/infra/persistence/batchwriter、将业务域异步 flush 到分析表、迁移 riskcontrol/节点访问日志/可观测时序写入、或评估 asyncinsert 与背压策略时必须使用。本技能指导分层职责、各域独立 Writer 实例、repository 批量 API…

    288 GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Database Migration

    Rain-kl/OpenFlare

    Wavelet 项目专用:当新增或修改数据库表结构、索引、初始化数据、系统配置 seed、模板 seed、默认管理员、goose SQL 迁移、internal/infra/persistence/migrator、ClickHouse 分析库 DDL 或数据库升级流程时必须使用。本技能指导在 internal/infra/persistence/migrator/goose 下编写…

    288 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • File Upload

    Rain-kl/OpenFlare

    Wavelet 项目专用:当业务需要上传文件、读取已上传文件、在 Worker/任务中程序化摄取字节流、选择存储引擎能力、或排查 wuploads / 文件统计异常时必须使用。本技能指导 storage 与 upload 分层、upload.Ingest 策略选型、前后端接入与禁止旁路写表。

    288 GitHub stars~1.7k tokensUpdated today
    Auto-check passed

Works with

Questions about Cache Framework

What does Cache Framework do?

Wavelet 项目专用:当新增或修改业务缓存(RAM/Redis/DB 三层读路径)、缓存失效、多节点 pub/sub 同步、或评估高频读是否应接入缓存时必须使用。本技能说明系统标准缓存框架、参考实现、禁止写法与分布式一致性要求。. Cache Framework is an agent skill from Rain-kl/OpenFlare.

When should I use Cache Framework?

Cache Framework fits situations like: tasks that involve Event-driven systems.

How do I install Cache Framework in Claude Code?

Run `npx skills add Rain-kl/OpenFlare --skill cache-framework -a claude-code`. Or copy the skill folder (.agents/skills/cache-framework in Rain-kl/OpenFlare) into .claude/skills/cache-framework in your project. Claude Code loads it when a task matches its description.

How do I install Cache Framework in Codex?

Run `npx skills add Rain-kl/OpenFlare --skill cache-framework -a codex`. Or copy the skill folder (.agents/skills/cache-framework in Rain-kl/OpenFlare) into .agents/skills/cache-framework in your project. Codex loads it when a task matches its description.

Can I use Cache Framework in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Rain-kl/OpenFlare --skill cache-framework -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cache-framework, .gemini/skills/cache-framework, .github/skills/cache-framework and .opencode/skills/cache-framework in your project.

What does Cache Framework need to run?

Going by SKILL.md and its folder, Cache Framework needs the command-line tools its instructions call (go and make).

Does Cache Framework access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Cache Framework safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cache Framework use?

Cache Framework is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cache Framework use?

About 1.7k tokens (SKILL.md is roughly 6.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Cache Framework?

Skills that share tags, products or a category with Cache Framework: Flox Environments (affaan-m/ECC, 275k stars), Flox Environments (affaan-m/ECC, 275k stars), Redis Patterns (affaan-m/ECC, 275k stars) and Infra Audit (SethGammon/Citadel, 922 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cache Framework?

Rain-kl (a GitHub user) maintains it in Rain-kl/OpenFlare, which has 288 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on October 8, 2026.

Source: Rain-kl/OpenFlare on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.