zhenxun_bot/zhenxun/services/cache/config.py
HibiKier e7f3c210df
修复并发时数据库超时 (#2063)
* 🔧 修复和优化:调整超时设置,重构检查逻辑,简化代码结构

- 在 `chkdsk_hook.py` 中重构 `check` 方法,提取公共逻辑
- 更新 `CacheManager` 中的超时设置,使用新的 `CACHE_TIMEOUT`
- 在 `utils.py` 中添加缓存逻辑,记录数据库操作的执行情况

*  feat(auth): 添加并发控制,优化权限检查逻辑

* Update utils.py

* 🚨 auto fix by pre-commit hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-09 08:46:08 +08:00

39 lines
910 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"
# 缓存获取超时时间(秒)
CACHE_TIMEOUT = 10
# 默认缓存过期时间(秒)
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}",
}