Cleanup removes expired tokens and returns the number of tokens cleaned up
(ctx context.Context)
| 89 | |
| 90 | // Cleanup removes expired tokens and returns the number of tokens cleaned up |
| 91 | func (s *InMemoryRefreshTokenStore) Cleanup(ctx context.Context) (int, error) { |
| 92 | s.mu.Lock() |
| 93 | defer s.mu.Unlock() |
| 94 | |
| 95 | var cleaned int |
| 96 | now := time.Now() |
| 97 | |
| 98 | for token, data := range s.tokens { |
| 99 | if now.After(data.Expiry) { |
| 100 | delete(s.tokens, token) |
| 101 | cleaned++ |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | return cleaned, nil |
| 106 | } |
| 107 | |
| 108 | // Count returns the total number of active refresh tokens |
| 109 | func (s *InMemoryRefreshTokenStore) Count(ctx context.Context) (int, error) { |
no outgoing calls