Install any skill in seconds. Free to start, no credit card required.
Get Started Free →doccker/cc-redis-safety
当用户操作 Redis 相关代码(go-redis、Jedis、redis-py、ioredis)时触发。涵盖禁止 KEYS 命令、SCAN 替代、大 key 控制、Pipeline 批量、TTL 规范等安全与性能要点。
Passed 19 of 22 test cases with the skill, and 17 of 22 without it.
3 fixed16 passed either way2 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 3 test cases the skill fixed. Same model, same prompt, with and without the skill.
When invoking SET commands across any Redis client library, what requirement must always be met regarding key lifetime?
| Checked | Without skill | With skill |
|---|---|---|
| Requires explicit TTL or expiration on all keys | Missed | Passed |
The instructions your model reads when the skill loads.
防止 Redis 常见性能和稳定性问题,适用于所有语言。
| 禁止 | 替代 | 原因 |
|---|---|---|
KEYS * / KEYS pattern | SCAN 游标迭代 | KEYS 是 O(N) 阻塞操作,生产环境会导致 Redis 卡死 |
FLUSHDB / FLUSHALL | 按 key 前缀 SCAN + DEL | 全量删除风险极高 |
| 无 TTL 的 SET | 所有 key 必须设置 TTL | 避免内存泄漏 |
// Go (go-redis) ❌
keys, _ := rdb.Keys(ctx, "user:*").Result()
// Go (go-redis) ✅
var cursor uint64
for {
keys, cursor, _ = rdb.Scan(ctx, cursor, "user:*", 100).Result()
// 处理 keys
if cursor == 0 { break }
}
// Java (Jedis) ❌
Set<String> keys = jedis.keys("user:*");
// Java (Jedis) ✅
ScanParams params = new ScanParams().match("user:*").count(100);
String cursor = "0";
do {
ScanResult<String> result = jedis.scan(cursor, params);
test cases passed, vs 17 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.