Enhance AI and Redis integration for smoke logging features
- Added AI configuration options to .env.example and config.go for OpenAI integration. - Implemented Redis caching for session management in main.go and auth middleware. - Updated smoke logging service to support real smoking time (`smoke_at`) and AI advice retrieval. - Enhanced API routes to include endpoints for AI advice and unlock functionality for non-members. - Improved database schema with new tables for AI advice and unlock records. - Expanded documentation to cover new AI features and Redis caching implementation.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# Redis(可选)
|
||||
|
||||
当前项目引入 Redis 的主要目的:缓存 `session_key -> user`,减少每个受保护接口都查询 MySQL(尤其在并发增大时更明显)。
|
||||
|
||||
## 什么时候需要
|
||||
|
||||
- 访问量变大,MySQL 压力主要来自“鉴权查用户”这种高频读
|
||||
- 需要做更复杂的能力:限流、计数、分布式锁、异步队列等
|
||||
|
||||
## 配置
|
||||
|
||||
见 `.env.example`:
|
||||
|
||||
- `REDIS_ADDR`
|
||||
- `REDIS_PASSWORD`
|
||||
- `REDIS_DB`
|
||||
- `REDIS_KEY_PREFIX`
|
||||
- `REDIS_SESSION_TTL_SECONDS`
|
||||
|
||||
说明:
|
||||
- 如果不配置 `REDIS_ADDR`,程序会自动禁用 Redis,行为与之前一致。
|
||||
|
||||
Reference in New Issue
Block a user