NewTimeoutCache creates a TimeoutCache with the given timeout.
(timeout time.Duration)
| 43 | |
| 44 | // NewTimeoutCache creates a TimeoutCache with the given timeout. |
| 45 | func NewTimeoutCache(timeout time.Duration) *TimeoutCache { |
| 46 | return &TimeoutCache{ |
| 47 | timeout: timeout, |
| 48 | cache: make(map[any]*cacheEntry), |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // Add adds an item to the cache, with the specified callback to be called when |
| 53 | // the item is removed from the cache upon timeout. If the item is removed from |
no outgoing calls