1
0
Fork
You've already forked ttlmap
0
go module providing a key-value store with items expiration
  • Go 100%
2023年10月12日 08:09:32 +00:00
go.mod initial import 2023年09月14日 16:47:11 +00:00
README.md add copy-pasteable go get command 2023年09月14日 17:39:38 +00:00
ttlmap.go move public field first; prettify generated doc 2023年10月12日 08:09:32 +00:00
UNLICENSE add UNLICENSE 2023年09月14日 17:37:24 +00:00

ttlmap Go Documentation

ttlmap is a simple key-value store (a map) with an expiration attached to each entry.

$ go get go.omarpolo.com/ttlmap

To actually expire the items, tl.Expire() should be called "sometimes". When to schedule its execution depends on the application. Otherwise, tl.AutoExpire() is provided too: it runs a goroutine that issue tl.Expire() periodically to expire the items.

Example usage:

typestatestruct{/* ... */}varuserstate=ttlmap.New[int64,state](3*time.Hour)userstate.AutoExpire()

Since it uses the new fancy go generics it needs a recent-ish go version.