forked from TrueCloudLab/frostfs-node
[#1133] services/session: remove expired tokens every epoch
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
b3b3b8b20f
commit
0695ec4125
2 changed files with 17 additions and 0 deletions
|
@ -49,3 +49,15 @@ func (s *TokenStore) Get(ownerID *owner.ID, tokenID []byte) *PrivateToken {
|
|||
|
||||
return t
|
||||
}
|
||||
|
||||
// RemoveOld removes all tokens expired since provided epoch.
|
||||
func (s *TokenStore) RemoveOld(epoch uint64) {
|
||||
s.mtx.Lock()
|
||||
defer s.mtx.Unlock()
|
||||
|
||||
for k, tok := range s.tokens {
|
||||
if tok.ExpiredAt() <= epoch {
|
||||
delete(s.tokens, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue