缓存支持读取缓存key的剩余有效时间
This commit is contained in:
14
redis.go
14
redis.go
@ -11,6 +11,7 @@ import (
|
||||
"context"
|
||||
cacheAbstract "git.zhangdeman.cn/zhangdeman/cache/abstract"
|
||||
"git.zhangdeman.cn/zhangdeman/redis"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -38,6 +39,19 @@ func (r *Redis) Exist(ctx context.Context, instanceFlag string, key string) (boo
|
||||
return res.Result == "1", res.Err
|
||||
}
|
||||
|
||||
// TTL 获取key的剩余有效期
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:11 2024/10/9
|
||||
func (r *Redis) TTL(ctx context.Context, instanceFlag string, key string) (int64, error) {
|
||||
if nil == ctx {
|
||||
ctx = context.Background()
|
||||
}
|
||||
res := redis.Wrapper.TTL(ctx, instanceFlag, key)
|
||||
return wrapper.String(res.Result).ToInt64().Value, res.Err
|
||||
}
|
||||
|
||||
// Set 设置缓存
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
|
Reference in New Issue
Block a user