Documentation
¶
Index ¶
- Variables
- func Close()
- func Delete(key string) error
- func Exists(key string) bool
- func Get(key string) (string, error)
- func GetBytes(key string) ([]byte, error)
- func GetInt64(key string) (int64, error)
- func GetManyInt64(keys []string) (map[string]int64, error)
- func GetOnlineUserCount() (int, error)
- func Increment(key string, delta int64) (int64, error)
- func Set(key string, value string, ttl time.Duration) error
- func SetBytes(key string, value []byte, ttl time.Duration) error
- func SetUserOnline(userId string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound 键不存在 ErrNotFound = errors.New("kvstore: key not found") )
Functions ¶
func GetManyInt64 ¶
GetManyInt64 批量获取 int64 类型的计数器值 适用于列表页展示(如批量获取一页帖子的浏览量) 返回结果 map,key 为传入的 key,value 为计数值(不存在的 key 默认为 0)
func GetOnlineUserCount ¶
GetOnlineUserCount 获取当前在线用户数 通过遍历匹配前缀且未过期的 Key 数量来实现
func SetUserOnline ¶
SetUserOnline 标记用户在线,设置 3 分钟 TTL 每次用户活动时调用此方法续期
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.