Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 1.5 KB

README.md

File metadata and controls

36 lines (25 loc) · 1.5 KB

go-ttlmap

Build Status codecov Go Report Card GoDoc GitHub

Go TTL Map is a concurent map with entries expiring after a specified interval. This package requires go1.14 or newer.

Overview

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.

ToDo

  • Provide code examples
  • Improve documentation
  • Develop better tests for concurency and race conditions

License

See LICENSE.