dropExpired removes the records whose expiry is before now. It does nothing before nextExpiry, so a store full of unexpired records is not scanned on every call.
(now time.Time)
| 355 | // nothing before nextExpiry, so a store full of unexpired records is not |
| 356 | // scanned on every call. |
| 357 | func (s *MemorySessionRevocationStore) dropExpired(now time.Time) { |
| 358 | if !s.nextExpiry.IsZero() && !now.After(s.nextExpiry) { |
| 359 | return |
| 360 | } |
| 361 | s.nextExpiry = time.Time{} |
| 362 | for key, entry := range s.entries { |
| 363 | if now.After(entry.expiresAt) { |
| 364 | delete(s.entries, key) |
| 365 | continue |
| 366 | } |
| 367 | if s.nextExpiry.IsZero() || entry.expiresAt.Before(s.nextExpiry) { |
| 368 | s.nextExpiry = entry.expiresAt |
| 369 | } |
| 370 | } |
| 371 | } |