Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCacheKey ¶
GenerateCacheKey 生成标准化的缓存键 可以基于不同参数生成一致的键
Types ¶
type Cache ¶
type Cache interface { Get(key string) (value string, found bool, err error) Set(key string, value string, ttl time.Duration) error Delete(key string) error Clear() error }
Cache 缓存接口
type Config ¶
type Config struct { // 缓存类型: "memory", "redis" 等 Type string // Redis连接地址 (仅Redis缓存使用) RedisAddr string // Redis密码 (仅Redis缓存使用) RedisPassword string // Redis数据库编号 (仅Redis缓存使用) RedisDB int // 默认缓存过期时间 DefaultTTL time.Duration // 自动清理间隔时间 (仅内存缓存使用) CleanupInterval time.Duration }
Config 缓存配置
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache 基于go-cache实现的内存缓存
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache 基于Redis实现的缓存
Click to show internal directories.
Click to hide internal directories.