Documentation
¶
Index ¶
- Constants
- type Driver
- type MemoStore
- func (store *MemoStore) Delete(prefix string, keys ...string) error
- func (store *MemoStore) DeleteAll() error
- func (store *MemoStore) GarbageCollect(l logging.Logger)
- func (store *MemoStore) Get(key string) (any, bool)
- func (store *MemoStore) Gets(keys []string, prefix string) (map[string]any, []string)
- func (store *MemoStore) Persist(path string) error
- func (store *MemoStore) Restore(path string) error
- func (store *MemoStore) Set(key string, value any, ttl int) error
- func (store *MemoStore) Sets(values map[string]any, prefix string) error
- type RedisStore
- func (store *RedisStore) Delete(prefix string, keys ...string) error
- func (store *RedisStore) DeleteAll() error
- func (store *RedisStore) Get(key string) (any, bool)
- func (store *RedisStore) Gets(keys []string, prefix string) (map[string]any, []string)
- func (store *RedisStore) Persist(path string) error
- func (store *RedisStore) Restore(path string) error
- func (store *RedisStore) Set(key string, value any, ttl int) error
- func (store *RedisStore) Sets(values map[string]any, prefix string) error
Constants ¶
View Source
const DefaultCacheFile = "cache_persist.bin"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
// 设置值,ttl为过期时间,单位为秒
Set(key string, value any, ttl int) error
// 取值,并返回是否成功
Get(key string) (any, bool)
// 批量取值,返回成功取值的map即不存在的值
Gets(keys []string, prefix string) (map[string]any, []string)
// 批量设置值,所有的key都会加上prefix前缀
Sets(values map[string]any, prefix string) error
// Delete values by [Prefix + key]. If no ket is presented, all keys with given prefix will be deleted.
Delete(prefix string, keys ...string) error
// Save in-memory cache to disk
Persist(path string) error
// Restore cache from disk
Restore(path string) error
// Remove all entries
DeleteAll() error
}
Driver 键值缓存存储容器
type MemoStore ¶
MemoStore 内存存储驱动
func NewMemoStore ¶
NewMemoStore 新建内存存储
func (*MemoStore) GarbageCollect ¶
GarbageCollect 回收已过期的缓存
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore redis存储驱动
func NewRedisStore ¶
NewRedisStore 创建新的redis存储
func (*RedisStore) Delete ¶
func (store *RedisStore) Delete(prefix string, keys ...string) error
Delete 批量删除给定的键
func (*RedisStore) Persist ¶
func (store *RedisStore) Persist(path string) error
Persist Dummy implementation
func (*RedisStore) Restore ¶
func (store *RedisStore) Restore(path string) error
Restore dummy implementation
Click to show internal directories.
Click to hide internal directories.