key 设置48小时时效
This commit is contained in:
@@ -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) # 如果只存储一个整数值,字符串类型可能更简单
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user