Commit d4050765 authored by chenweijian's avatar chenweijian

group support

parent 3b613ec7
......@@ -125,3 +125,17 @@ func DecrNum(key string, num int64) (int64, error) {
}
return resNum, nil
}
func SetExpire(key string, expiration time.Duration) error {
ttl, err := RedisClient.TTL(context.Background(), key).Result()
if err != nil {
return err
}
if ttl == -1 {
err = RedisClient.Expire(context.Background(), key, expiration).Err()
if err != nil {
return err
}
}
return nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment