Store adds or updates a value in the cache with the configured TTL.
(key K, value V)
| 56 | |
| 57 | // Store adds or updates a value in the cache with the configured TTL. |
| 58 | func (c *TTLCache[K, V]) Store(key K, value V) { |
| 59 | c.entries.Store(key, ttlEntry[V]{ |
| 60 | value: value, |
| 61 | expiresAt: time.Now().Add(c.ttl), |
| 62 | }) |
| 63 | } |
| 64 | |
| 65 | // evict removes all expired entries. |
| 66 | func (c *TTLCache[K, V]) evict() { |
no outgoing calls