Go TTL Map is a concurent map with entries expiring after a specified interval. This package
requires go1.14
or newer.
This implementation of TTL Map creates a separate goroutine for each map entry that takes care of entry expiry.
PutXXX()
methods take parent context as one of the parameters and entries are
safely removed from the map when associated context is canceled.
This design can potentially create a race conditions but measures had been taken to address this issue. In particular, random delay in 0-100,000us range is added to every TTL to reduce probability of race condition when large number of entries is added to the map in a rapid succession.
A similar condition may occur on context cancellation but impact of it is rather negligeable.
- Provide code examples
- Improve documentation
- Develop better tests for concurency and race conditions
See LICENSE.