Skip to content

A concurrent map with entries expiring after a specified interval.

License

Notifications You must be signed in to change notification settings

dtoubelis/go-ttlmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A concurrent map with entries expiring after a specified interval.

Resources

License

Stars

Watchers

Forks

Packages

No packages published