Set stores a value with the given TTL
(key string, value T, ttl time.Duration)
| 33 | |
| 34 | // Set stores a value with the given TTL |
| 35 | func (m *ExpiryMap[T]) Set(key string, value T, ttl time.Duration) { |
| 36 | m.store.Set(key, val[T]{ |
| 37 | value: value, |
| 38 | expires: time.Now().Add(ttl), |
| 39 | }) |
| 40 | } |
| 41 | |
| 42 | // GetOk retrieves a value and checks if it exists and hasn't expired |
| 43 | // Performs lazy cleanup of expired entries on access |
no outgoing calls