Token导航 LogoToken导航

Agent Skill · 开发规范

redis-best-practices(Redis 最佳实践)

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

redis-best-practices 是开发规范类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,第三方扫描有未通过项,按安装量在开发规范类的 1,265 个 Skill 里排第 82。

总安装 32,928周安装 1,391GitHub Stars 87下载 11,536核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/mindrally/skills --skill redis-best-practices

这个 Skill 是做什么的

开发规范类 Skill 用来统一代码风格、目录结构和评审口径,产出多为检查清单或改写建议。

Redis 缓存、数据结构和高性能操作的开发最佳实践。

涵盖五种核心数据结构(字符串、散列、列表、集合、排序集合)以及流,以及每个数据结构的命令示例和用例指南 包括三种缓存模式(高速缓存、直写、失效)以及伪代码和 TTL 策略,以防止雷群 通过复制、Sentinel 和带有用于密钥分发的哈希标签的集群配置来解决高可用性问题 为原子操作提供事务和 Lua 脚本模式,以及发布/订阅消息传递、持久性 (RDB/AOF) 和安全强化 涵盖监控、连接池和性能优化技术,包括管道和内存管理

来源仓库内路径:skills/redis-best-practices

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/mindrally/skills --skill redis-best-practices;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

redis-best-practices 怎么安装?

在终端执行 npx skills add https://github.com/mindrally/skills --skill redis-best-practices。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

redis-best-practices 支持哪些 AI 工具?

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

redis-best-practices 需要什么权限?

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

redis-best-practices 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

redis-best-practices 用的人多吗?

公开数据是累计安装 32,928 次,近一周安装 1,391 次,下载 11,536 次,GitHub 87 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

redis-best-practices 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

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

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发规范类任务、又不想每次都手写提示词的人。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

开发规范类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
vercel-react-best-practices

Vercel React 最佳实践 · Codex、Claude

8,490,72025,918操作浏览器MIT通过
web-design-guidelines

网页设计指南 · Codex、Claude

6,686,01625,885需要联网MIT有提醒
remotion-best-practices

Remotion 最佳实践 · Codex、Claude

6,505,6323,027操作浏览器MIT有提醒
supabase-postgres-best-practices

Supabase Postgres 最佳实践 · Codex、Claude

3,175,5232,030需要联网MIT通过
next-best-practices

Next.js 最佳实践 · Codex、Claude

1,848,240841操作浏览器MIT通过
redis-best-practices

Redis 最佳实践 · 本页

32,92887需要联网MIT未通过

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

SKILL.md 原文

Redis Best Practices

Core Principles

  • Use Redis for caching, session storage, real-time analytics, and message queuing
  • Choose appropriate data structures for your use case
  • Implement proper key naming conventions and expiration policies
  • Design for high availability and persistence requirements
  • Monitor memory usage and optimize for performance

Key Naming Conventions

  • Use colons as namespace separators
  • Include object type and identifier in key names
  • Keep keys short but descriptive
  • Use consistent naming patterns across your application
# Good key naming examples
user:1234:profile
user:1234:sessions
order:5678:items
cache:api:products:list
queue:email:pending
session:abc123def456
rate_limit:api:user:1234

Data Structures

Strings

  • Use for simple key-value storage, counters, and caching
  • Consider using MGET/MSET for batch operations
# Simple caching
SET cache:user:1234 '{"name":"John","email":"john@example.com"}' EX 3600

# Counters
INCR stats:pageviews:homepage
INCRBY stats:downloads:file123 5

# Atomic operations
SETNX lock:resource:456 "owner:abc" EX 30

Hashes

  • Use for objects with multiple fields
  • More memory-efficient than multiple string keys
  • Supports partial updates
# Store user profile
HSET user:1234 name "John Doe" email "john@example.com" created_at "2024-01-15"

# Get specific fields
HGET user:1234 email
HMGET user:1234 name email

# Increment numeric fields
HINCRBY user:1234 login_count 1

# Get all fields
HGETALL user:1234

Lists

  • Use for queues, recent items, and activity feeds
  • Consider blocking operations for queue consumers
# Message queue
LPUSH queue:emails '{"to":"user@example.com","subject":"Welcome"}'
RPOP queue:emails

# Blocking pop for workers
BRPOP queue:emails 30

# Recent activity (keep last 100)
LPUSH user:1234:activity "viewed product 567"
LTRIM user:1234:activity 0 99

# Get recent items
LRANGE user:1234:activity 0 9

Sets

  • Use for unique collections, tags, and relationships
  • Supports set operations (union, intersection, difference)
# User tags/interests
SADD user:1234:interests "technology" "music" "travel"

# Check membership
SISMEMBER user:1234:interests "music"

# Find common interests
SINTER user:1234:interests user:5678:interests

# Online users tracking
SADD online:users "user:1234"
SREM online:users "user:1234"
SMEMBERS online:users

Sorted Sets

  • Use for leaderboards, priority queues, and time-series data
  • Elements sorted by score
# Leaderboard
ZADD leaderboard:game1 1500 "player:123" 2000 "player:456" 1800 "player:789"

# Get top 10
ZREVRANGE leaderboard:game1 0 9 WITHSCORES

# Get player rank
ZREVRANK leaderboard:game1 "player:123"

# Time-based data (score = timestamp)
ZADD events:user:1234 1705329600 "login" 1705330000 "purchase"

# Get events in time range
ZRANGEBYSCORE events:user:1234 1705329600 1705333200

Streams

  • Use for event streaming and log data
  • Supports consumer groups for distributed processing
# Add events to stream
XADD events:orders * customer_id 1234 product_id 567 amount 99.99

# Read from stream
XREAD COUNT 10 STREAMS events:orders 0

# Consumer groups
XGROUP CREATE events:orders order-processors $ MKSTREAM
XREADGROUP GROUP order-processors worker1 COUNT 10 STREAMS events:orders >

# Acknowledge processed messages
XACK events:orders order-processors 1234567890-0

Caching Patterns

Cache-Aside Pattern

# Pseudo-code for cache-aside
def get_user(user_id):
    # Try cache first
    cached = redis.get(f"cache:user:{user_id}")
    if cached:
        return json.loads(cached)

    # Cache miss - fetch from database
    user = database.get_user(user_id)

    # Store in cache with expiration
    redis.setex(f"cache:user:{user_id}", 3600, json.dumps(user))

    return user

Write-Through Pattern

def update_user(user_id, data):
    # Update database
    database.update_user(user_id, data)

    # Update cache
    redis.setex(f"cache:user:{user_id}", 3600, json.dumps(data))

Cache Invalidation

# Delete specific cache
DEL cache:user:1234

# Delete by pattern (use with caution in production)
# Use SCAN instead of KEYS for large datasets
SCAN 0 MATCH cache:user:* COUNT 100

# Tag-based invalidation using sets
SADD cache:tags:user:1234 "cache:user:1234:profile" "cache:user:1234:orders"
# Invalidate all related caches
SMEMBERS cache:tags:user:1234
# Then delete each key

Expiration and Memory Management

TTL Best Practices

  • Always set TTL on cache keys
  • Use jitter to prevent thundering herd
  • Consider sliding expiration for session data
# Set with expiration
SET cache:data:123 "value" EX 3600

# Set expiration on existing key
EXPIRE cache:data:123 3600

# Check TTL
TTL cache:data:123

# Persist key (remove expiration)
PERSIST cache:data:123

Memory Management

# Check memory usage
INFO memory

# Get key memory usage
MEMORY USAGE cache:large:object

# Configure max memory policy
CONFIG SET maxmemory 2gb
CONFIG SET maxmemory-policy allkeys-lru

Transactions and Atomicity

MULTI/EXEC Transactions

# Transaction block
MULTI
INCR stats:views
LPUSH recent:views "page:123"
EXEC

# Watch for optimistic locking
WATCH user:1234:balance
balance = GET user:1234:balance
MULTI
SET user:1234:balance (balance - 100)
EXEC

Lua Scripts

  • Use for complex atomic operations
  • Scripts execute atomically
-- Rate limiting script
local key = KEYS[1]
local limit = tonumber(ARGV[1])
local window = tonumber(ARGV[2])

local current = tonumber(redis.call('GET', key) or '0')

if current >= limit then
    return 0
end

redis.call('INCR', key)
if current == 0 then
    redis.call('EXPIRE', key, window)
end

return 1
# Execute Lua script
EVAL "return redis.call('GET', KEYS[1])" 1 mykey

Pub/Sub and Messaging

# Publisher
PUBLISH channel:notifications '{"type":"alert","message":"New order"}'

# Subscriber
SUBSCRIBE channel:notifications

# Pattern subscription
PSUBSCRIBE channel:*

High Availability

Replication

  • Use replicas for read scaling
  • Configure proper persistence on master
# On replica
REPLICAOF master_host 6379

# Check replication status
INFO replication

Redis Sentinel

  • Use for automatic failover
  • Deploy at least 3 Sentinel instances

Redis Cluster

  • Use for horizontal scaling
  • Data automatically sharded across nodes
  • Use hash tags for related keys
# Hash tags ensure keys go to same slot
SET {user:1234}:profile "data"
SET {user:1234}:settings "data"

Persistence

RDB Snapshots

# Manual snapshot
BGSAVE

# Configure automatic snapshots
CONFIG SET save "900 1 300 10 60 10000"

AOF (Append-Only File)

# Enable AOF
CONFIG SET appendonly yes
CONFIG SET appendfsync everysec

# Rewrite AOF
BGREWRITEAOF

Security

  • Require authentication
  • Use TLS for connections
  • Bind to specific interfaces
  • Disable dangerous commands
# Set password
CONFIG SET requirepass "your_strong_password"

# Authenticate
AUTH your_strong_password

# Rename dangerous commands (in redis.conf)
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command KEYS ""

Monitoring

# Server info
INFO

# Memory stats
INFO memory

# Client connections
CLIENT LIST

# Slow log
SLOWLOG GET 10

# Monitor commands (debug only)
MONITOR

# Key count per database
INFO keyspace

Connection Management

  • Use connection pooling
  • Set appropriate timeouts
  • Handle reconnection gracefully
# Python example with connection pool
import redis

pool = redis.ConnectionPool(
    host='localhost',
    port=6379,
    max_connections=50,
    socket_timeout=5,
    socket_connect_timeout=5
)

redis_client = redis.Redis(connection_pool=pool)

Performance Tips

  • Use pipelining for batch operations
  • Avoid large keys (>100KB values)
  • Use SCAN instead of KEYS in production
  • Monitor and optimize memory usage
  • Consider using RedisJSON for complex JSON operations
# Pipeline example (pseudo-code)
pipe = redis.pipeline()
pipe.get("key1")
pipe.get("key2")
pipe.set("key3", "value")
results = pipe.execute()

平台分布

Antigravity

26.32%
按下载量换算3,036

Claude Code

22.07%
按下载量换算2,546

Gemini CLI

20.19%
按下载量换算2,329

OpenCode

12.75%
按下载量换算1,471

Cursor

7.7%
按下载量换算888

github-copilot

3.56%
按下载量换算411

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

需要联网

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills