Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
* Update the example in the README and small.go example
* Version bump in ttlMap.go
  • Loading branch information
jftuga committed Nov 8, 2023
1 parent f770ab3 commit a057dea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func main() {
startSize := 3 // initial number of items in map
pruneInterval := time.Duration(time.Second * 1) // search for expired items every 'pruneInterval' seconds
refreshLastAccessOnGet := true // update item's 'lastAccessTime' on a .Get()

// any comparable data type such as int, uint64, pointers and struct types (if all field types are comparable)
// can be used as the key type, not just string
t := TtlMap.New[string](maxTTL, startSize, pruneInterval, refreshLastAccessOnGet)
defer t.Close()

Expand Down Expand Up @@ -84,6 +87,7 @@ TtlMap length: 0
* Adopted from: [Map with TTL option in Go](https://stackoverflow.com/a/25487392/452281)
* * Answer created by: [OneOfOne](https://stackoverflow.com/users/145587/oneofone)
* [/u/skeeto](https://old.reddit.com/user/skeeto): suggestions for the `New` function
* `@zhayes` on the Go Discord: helping me with Go Generics

## Disclosure Notification

Expand Down
3 changes: 3 additions & 0 deletions example/small/small.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ func main() {
startSize := 3 // initial number of items in map
pruneInterval := time.Duration(time.Second * 1) // search for expired items every 'pruneInterval' seconds
refreshLastAccessOnGet := true // update item's 'lastAccessTime' on a .Get()

// any comparable data type such as int, uint64, pointers and struct types (if all field types are comparable)
// can be used as the key type, not just string
t := TtlMap.New[string](maxTTL, startSize, pruneInterval, refreshLastAccessOnGet)
defer t.Close()

Expand Down
2 changes: 1 addition & 1 deletion ttlMap.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"
)

const version string = "1.4.0"
const version string = "1.5.0"

type CustomKeyType interface {
comparable
Expand Down

0 comments on commit a057dea

Please sign in to comment.