zhenxun_bot/zhenxun/services/cache/config.py
HibiKier 56162e24ea ♻️ 重构cache
2025-07-10 17:10:07 +08:00

36 lines
854 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
缓存系统配置
"""
# 日志标识
LOG_COMMAND = "CacheRoot"
# 默认缓存过期时间(秒)
DEFAULT_EXPIRE = 600
# 缓存键前缀
CACHE_KEY_PREFIX = "ZHENXUN"
# 缓存键分隔符
CACHE_KEY_SEPARATOR = ":"
# 复合键分隔符用于分隔tuple类型的cache_key_field
COMPOSITE_KEY_SEPARATOR = "_"
# 缓存模式
class CacheMode:
# 内存缓存 - 使用内存存储缓存数据
MEMORY = "MEMORY"
# Redis缓存 - 使用Redis服务器存储缓存数据
REDIS = "REDIS"
# 不使用缓存 - 将使用ttl=0的内存缓存相当于直接从数据库获取数据
NONE = "NONE"
SPECIAL_KEY_FORMATS = {
"LEVEL": "{user_id}" + COMPOSITE_KEY_SEPARATOR + "{group_id}",
"BAN": "{user_id}" + COMPOSITE_KEY_SEPARATOR + "{group_id}",
"GROUPS": "{group_id}" + COMPOSITE_KEY_SEPARATOR + "{channel_id}",
}