session provider에도 touch 추가

This commit is contained in:
2023-09-04 11:56:56 +09:00
parent d396a35713
commit 0eefb438a6
3 changed files with 33 additions and 0 deletions

View File

@ -87,6 +87,20 @@ func (p *provider_redis) Query(pk string) (*Authorization, error) {
return &auth, nil
}
func (p *provider_redis) Touch(pk string) (bool, error) {
sk := publickey_to_storagekey(publickey(pk))
ok, err := p.redisClient.Expire(p.ctx, string(sk), p.ttl).Result()
if err == redis.Nil {
// 이미 만료됨
return false, nil
} else if err != nil {
logger.Println("consumer Touch :", err)
return false, err
}
return ok, nil
}
type consumer_redis struct {
consumer_common[*sessionRedis]
redisClient *redis.Client