缓存预热加锁

This commit is contained in:
2025-05-07 12:09:17 +08:00
parent f1a65c1ed8
commit 94fdab4e36
2 changed files with 37 additions and 38 deletions

View File

@ -12,57 +12,25 @@ import (
)
// ICache 缓存定义
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:49 2024/6/3
type ICache interface {
// Enable 是否启用缓存(总开关)
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:50 2024/6/3
Enable() bool
// CacheTime 缓存时长, 单位 : s , 默认 1800, 最小值 90, 设置失效时间, 会上下波动60s, 避免缓存集中失效
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:50 2024/6/3
CacheTime() int64
// IsAllow 针对当前请求数据和状态, 是否允许缓存
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:52 2024/6/3
IsAllow(reqCfg *define.Request, response *define.Response) bool
// GetKey 获取缓存key
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:51 2024/6/3
GetKey(reqCfg *define.Request) string
// GetValue 获取缓存值
//
// Author : zhangdeman001@ke.com<张德满>
//
// Date : 16:01 2024/6/3
GetValue(cacheKey string) string
// SetValue 设置缓存
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 16:46 2024/6/3
SetValue(cacheKey string, cacheValue string) error
// TTL 缓存剩余生命周期(单位: s)
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 18:39 2024/10/9
TTL(cacheKey string) int64
// PreHeatConfig 缓存预热配置
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 18:42 2024/10/9
PreHeatConfig() *define.CachePreHeatConfig
// Lock 设置缓存时加锁
Lock(lockKey string) error
// Unlock 完成缓存设置时, 释放锁
Unlock(lockKey string) error
}