Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IAppCache ¶
type IAppCache interface {
// 默认缓存过期时间
DefaultExpiration() time.Duration
// 从map数据中加载
LoadMap(items map[string]any)
// 注册缓存,如果缓存不存在或过期,则自动使用getter获取数据并添加缓存
Register(key string, expire time.Duration, getter func() any)
// 获取缓存数据,如果缓存不存在或已过期返回 nil, 并在获取时检查并重置过期
Get(key string) (any, bool)
// 设置缓存数据,与Register不同的是,一旦过期将不会自动存入
Set(key string, value any, expire time.Duration)
// 更新缓存:缓存数据存在且未过期
Replace(key string, value any, expire time.Duration) error
// 添加缓存:缓存数据不存在或已过期
Add(key string, value any, expire time.Duration) error
// 删除缓存数据
Delete(key string)
// 清空所有缓存数据
Flush()
}
type IApplication ¶
Click to show internal directories.
Click to hide internal directories.