go module providing a key-value store with items expiration
- Go 100%
| go.mod | initial import | |
| README.md | add copy-pasteable go get command | |
| ttlmap.go | move public field first; prettify generated doc | |
| UNLICENSE | add UNLICENSE | |
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.