key 设置48小时时效

This commit is contained in:
liuwei
2025-02-05 14:02:00 +08:00
parent 4c13b552d8
commit f0a5cfe092
2 changed files with 5 additions and 1 deletions

View File

@@ -13,8 +13,11 @@ def process_message(message:WxMsg):
current_date = datetime.now().strftime('%Y-%m-%d')
# 生成Redis key
key = f"{message.roomid}:{message.sender}:{current_date}:count"
# 使用Redis哈希或字符串增加发言次数
r.hincrby(key, 'count', 1) # 这里使用哈希但也可以考虑用字符串的INCR操作
# 设置时效为48小时
r.expire(key,86400*2)
# 或者使用字符串r.incr(key) # 如果只存储一个整数值,字符串类型可能更简单