hi-server/scripts/clear_user_cache.sh
2026-01-27 03:13:15 -08:00

15 lines
455 B
Bash

#!/bin/bash
# 批量清除用户缓存脚本
# 用法: ./clear_user_cache.sh
echo "正在清除所有用户缓存 (cache:user:id:*)..."
# 方法 1: 使用 xargs (适用于 Key 数量不是特别巨大的情况)
redis-cli KEYS "cache:user:id:*" | xargs -r redis-cli DEL
# 或者如果您的 Key 非常多,可以使用 SCAN 命令 (更安全,防堵塞)
# redis-cli --scan --pattern "cache:user:id:*" | xargs -r redis-cli DEL
echo "清除完成。"