Token导航 LogoToken导航

Agent Skill · 前端设计

go-cache(去缓存)

go-cache 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

go-cache 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 6,787。

总安装 456周安装 19GitHub Stars 公开资料未说明下载 152核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-cache

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态进行整理。通过 npx skills add 命令从指定 GitHub 仓库安装,需确认权限范围。使用前建议核验是否会触发联网或文件读写操作。

go-cache 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/go-cache

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-cache;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

go-cache 怎么安装?

在终端执行 npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-cache。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

go-cache 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

go-cache 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

go-cache 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

go-cache 用的人多吗?

公开数据是累计安装 456 次,近一周安装 19 次,下载 152 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

go-cache 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
go-cache

去缓存 · 本页

456—只读未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Go Cache

Generate two files for every cache: a port interface and a Redis-backed implementation.

When to Use

  • Create a cache layer for any module
  • Redis-backed TTL storage (OTP, sessions, OAuth state)
  • Rate limiting storage
  • Boolean flag caching (existence checks)
  • JSON data caching (structured objects)

Which Variant?

Pick before writing anything:

ScenarioVariantGet return type
Flag, existence check, rate limitBoolean flagbool
Structured data — tokens, sessions, profilesJSON data*dto.XxxData

For TTL:

  • Fixed TTL — short-lived or individually written entries (OTPs, OAuth state, rate limits, sessions)
  • Randomized TTL — long-lived entries written in bulk (activation flags, daily metrics) — prevents cache stampede

Two-File Pattern

Every cache requires exactly two files:

  1. Port interface: internal/modules/<module>/ports/<cache_name>_cache.go
  2. Cache implementation: internal/modules/<module>/cache/<cache_name>_cache.go

File Layout Order

  1. Constants (key prefix, TTL)
  2. Implementation struct (XxxCache)
  3. Compile-time interface assertion
  4. Constructor (NewXxxCache)
  5. Methods (Set, Get, Delete)
  6. Helper methods (buildKey, calculateTTL)

Boolean Flag Cache

Use when caching simple existence flags, presence checks, or rate limit states.

  • Store "1" as the value
  • Return false, nil when the key doesn't exist (not an error)

Port

package ports

import "context"

// XxxCache describes ...
type XxxCache interface {
	Set(ctx context.Context, id uint64) error
	Get(ctx context.Context, id uint64) (bool, error)
	Delete(ctx context.Context, id uint64) error
}

Implementation

package cache

import (
	"context"
	"errors"
	"fmt"
	"time"

	"github.com/cristiano-pacheco/bricks/pkg/redis"
	"github.com/cristiano-pacheco/pingo/internal/modules/<module>/ports"
	redislib "github.com/redis/go-redis/v9"
)

const (
	entityCacheKeyPrefix = "entity_name:"
	entityCacheTTL       = 10 * time.Minute
)

type EntityCache struct {
	redisClient redis.UniversalClient
}

var _ ports.EntityCache = (*EntityCache)(nil)

func NewEntityCache(redisClient redis.UniversalClient) *EntityCache {
	return &EntityCache{
		redisClient: redisClient,
	}
}

func (c *EntityCache) Set(ctx context.Context, id uint64) error {
	key := c.buildKey(id)
	return c.redisClient.Set(ctx, key, "1", entityCacheTTL).Err()
}

func (c *EntityCache) Get(ctx context.Context, id uint64) (bool, error) {
	key := c.buildKey(id)
	result := c.redisClient.Get(ctx, key)
	if err := result.Err(); err != nil {
		if errors.Is(err, redislib.Nil) {
			return false, nil
		}
		return false, err
	}
	return true, nil
}

func (c *EntityCache) Delete(ctx context.Context, id uint64) error {
	key := c.buildKey(id)
	return c.redisClient.Del(ctx, key).Err()
}

func (c *EntityCache) buildKey(id uint64) string {
	return fmt.Sprintf("%s%d", entityCacheKeyPrefix, id)
}

JSON Data Cache

Use when caching structured data. Data structs are defined in the dto package, never in ports.

  • Serialize with json.Marshal before storing
  • Deserialize with json.Unmarshal when retrieving
  • Return nil, nil on missing key — unless the key is always expected to exist, in which case return a domain error (e.g., errs.ErrXxxNotFound)
  • Use distinct variable names (getErr, unmarshalErr) to avoid shadowing

Port

package ports

import (
	"context"

	"github.com/cristiano-pacheco/pingo/internal/modules/<module>/dto"
}

// XxxCache describes ...
type XxxCache interface {
	Set(ctx context.Context, key string, data dto.XxxData) error
	Get(ctx context.Context, key string) (dto.XxxData, error)
	Delete(ctx context.Context, key string) error
}

Implementation

package cache

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"time"

	"github.com/cristiano-pacheco/bricks/pkg/redis"
	"github.com/cristiano-pacheco/pingo/internal/modules/<module>/dto"
	"github.com/cristiano-pacheco/pingo/internal/modules/<module>/ports"
	redislib "github.com/redis/go-redis/v9"
)

const (
	entityCacheKeyPrefix = "entity_name:"
	entityCacheTTL       = 10 * time.Minute
)

type EntityCache struct {
	redisClient redis.UniversalClient
}

var _ ports.EntityCache = (*EntityCache)(nil)

func NewEntityCache(redisClient redis.UniversalClient) *EntityCache {
	return &EntityCache{
		redisClient: redisClient,
	}
}

func (c *EntityCache) Set(ctx context.Context, key string, data dto.EntityData) error {
	cacheKey := c.buildKey(key)
	jsonData, err := json.Marshal(data)

	if err != nil {
		return fmt.Errorf("marshal entity data: %w", err)
	}

	return c.redisClient.Set(ctx, cacheKey, jsonData, entityCacheTTL).Err()
}

func (c *EntityCache) Get(ctx context.Context, key string) (dto.EntityData, error) {
	cacheKey := c.buildKey(key)
	result := c.redisClient.Get(ctx, cacheKey)

	if getErr := result.Err(); getErr != nil {
		if errors.Is(getErr, redislib.Nil) {
			return dto.EntityData{}, nil
		}
		return dto.EntityData{}, getErr
	}

	jsonData, err := result.Bytes()

	if err != nil {
		return dto.EntityData{}, fmt.Errorf("get bytes: %w", err)
	}

	var entityData dto.EntityData
	if unmarshalErr := json.Unmarshal(jsonData, &entityData); unmarshalErr != nil {
		return dto.EntityData{}, fmt.Errorf("unmarshal entity data: %w", unmarshalErr)
	}

	return entityData, nil
}

func (c *EntityCache) Delete(ctx context.Context, key string) error {
	cacheKey := c.buildKey(key)
	return c.redisClient.Del(ctx, cacheKey).Err()
}

func (c *EntityCache) buildKey(key string) string {
	return entityCacheKeyPrefix + key
}

Key Building

String ID (simple concatenation):

func (c *EntityCache) buildKey(id string) string {
	return entityCacheKeyPrefix + id
}

Uint64 ID:

func (c *EntityCache) buildKey(id uint64) string {
	return fmt.Sprintf("%s%d", entityCacheKeyPrefix, id)
}

Composite key:

func (c *EntityCache) buildKey(userID uint64, resourceID string) string {
	return fmt.Sprintf("%s%d:%s", entityCacheKeyPrefix, userID, resourceID)
}

TTL Configuration

Fixed TTL — for short-lived data where stampede is not a concern:

const (
	entityCacheKeyPrefix = "entity_name:"
	entityCacheTTL       = 10 * time.Minute
)

Randomized TTL — for long-lived data created in bulk (prevents cache stampede):

import "math/rand"

const (
	entityCacheKeyPrefix = "entity_name:"
	entityCacheTTLMin    = 23 * time.Hour
	entityCacheTTLMax    = 25 * time.Hour
)

func (c *EntityCache) calculateTTL() time.Duration {
	min := entityCacheTTLMin.Milliseconds()
	max := entityCacheTTLMax.Milliseconds()
	randomMs := min + rand.Int63n(max-min+1)
	return time.Duration(randomMs) * time.Millisecond
}

Common TTL ranges:

  • 5-15 minutes — OTP codes, OAuth state, rate limits
  • 50-70 minutes — User sessions
  • 12-25 hours — Activation flags, daily metrics
  • 6.5-7.5 days — Weekly aggregations

Naming

  • Port interface: XxxCache (ports package, no suffix)
  • Implementation struct: XxxCache (cache package — same name, disambiguated by package)
  • Constructor: NewXxxCache, returns *XxxCache
  • Constants: lowercase, package-level (e.g. entityCacheKeyPrefix, entityCacheTTL)

Fx Wiring

Add to internal/modules/<module>/module.go:

fx.Provide(
	fx.Annotate(
		cache.NewXxxCache,
		fx.As(new(ports.XxxCache)),
	),
),

Dependencies

  • redis.UniversalClient from "github.com/cristiano-pacheco/bricks/pkg/redis"
  • redislib "github.com/redis/go-redis/v9" for nil detection

Critical Rules

  1. No standalone functions: When a file contains a struct with methods, do not add standalone functions. Use private methods on the struct instead.
  2. Two files: Port in ports/, implementation in cache/
  3. Interface assertion: var _ ports.XxxCache = (*XxxCache)(nil) immediately below the struct
  4. Constructor: Returns *XxxCache (pointer)
  5. Context: Always accept ctx context.Context as first parameter — never call context.Background() internally
  6. Redis nil: Import redislib "github.com/redis/go-redis/v9" and check with errors.Is(err, redislib.Nil)
  7. TTL scope: TTL is an implementation detail — never expose it as a method parameter
  8. buildKey: Always use a buildKey() helper; + for string IDs, fmt.Sprintf for numeric IDs
  9. Missing keys: Boolean cache returns false, nil; JSON cache returns nil, nil (or a domain error if the key must exist)
  10. DTOs in dto package: Data structs belong in dto/, never defined inline in ports/
  11. No method comments: Only port interfaces get doc comments; implementation methods do not
  12. Error messages: "action noun: %w" format (e.g., "marshal oauth state: %w", "get bytes: %w")

Workflow

  1. Decide variant: Boolean flag or JSON data?
  2. Create port interface in ports/<name>_cache.go
  3. Create cache implementation in cache/<name>_cache.go
  4. Add Fx wiring to module.go
  5. Run make lint
  6. Run make nilaway

平台分布

Codex

33.82%
按下载量换算51

Claude

29.63%
按下载量换算45

Cursor

19.83%
按下载量换算30

Gemini CLI

9.24%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills