Documentation
¶
Index ¶
- func Clear(cache Cache) error
- func Delete(cache Cache, key string) error
- func Expire(cache Cache, key string, expireSec int64) error
- func Get[T any](cache Cache, key string) (T, error)
- func GetAll(cache Cache) (map[string]string, error)
- func GetMulti(cache Cache, keys []string) (map[string]string, error)
- func Set(cache Cache, key string, value any, expireSec int64) error
- func TTL(cache Cache, key string) (int64, error)
- type Cache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Expire ¶ added in v1.4.9
Expire 使用秒数设置key的过期时间 参数: - cache: 缓存基础设施接口 - expireSec: 缓存过期时间,单位秒 返回值: - 错误
func GetMulti ¶
GetMulti 批量获取缓存值 参数: - cache: 缓存基础设施接口 - keys: 缓存的键(多个) 返回值: - 缓存值,value以string类型先返回 - 错误
Types ¶
type Cache ¶
type Cache interface {
// Set 设置缓存值
Set(key string, value string, expireSec int64) error
// Get 获取缓存值
Get(key string) (string, error)
// GetMulti 获取多个缓存值
GetMulti(keys []string) (map[string]string, error)
// GetAll 获取所有缓存值
GetAll() (map[string]string, error)
// Delete 删除缓存值
Delete(key string) error
// Clear 清除缓存
Clear() error
// Expire 使用秒数设置key的过期时间
Expire(key string, expireSec int64) error
// TTL 获取过期剩余秒数
TTL(key string) (int64, error)
}
Cache 缓存基础设施接口
Click to show internal directories.
Click to hide internal directories.