Rename package
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/tag/woodpecker Pipeline was successful Details

master v1.0.1
Caj Larsson 2 years ago
parent 1f527b6dd9
commit 6755b37199

@ -203,7 +203,7 @@ func TestFlush(t *testing.T) {
}
func TestOnEvicted(t *testing.T) {
tc := New[string, int](DefaultExpiration, 0)
tc := New[string, int](DefaultExpiration, time.Millisecond)
tc.Set("foo", 3, DefaultExpiration)
if tc.onEvicted != nil {
t.Fatal("tc.onEvicted is not nil")

@ -4,13 +4,14 @@ import (
"fmt"
"time"
"github.com/num30/go-cache"
"git.sg.caj.me/caj/go-cache"
)
func main() {
// Create a cache with a default expiration time of 5 minutes, and which
// purges expired items every 10 minutes
c := cache.New[string](5*time.Minute, 10*time.Minute)
c := cache.New[string, string](5*time.Minute, 10*time.Minute)
// Set the value of the key "foo" to "bar", with the default expiration time
c.Set("foo", "bar", cache.DefaultExpiration)
@ -27,7 +28,7 @@ func main() {
}
// Want performance? Store pointers!
structCache := cache.New[*time.Time](5*time.Minute, 10*time.Minute)
structCache := cache.New[string, *time.Time](5*time.Minute, 10*time.Minute)
structCache.Set("foo", &time.Time{}, cache.DefaultExpiration)
if x, found := structCache.Get("foo"); found {
fmt.Printf("Cached time %+v\n", x)

@ -1,10 +1,10 @@
module github.com/num30/go-cache
module git.sg.caj.me/caj/go-cache
go 1.18
require (
github.com/golangci/golangci-lint v1.45.2
honnef.co/go/tools v0.3.1 // indirect
honnef.co/go/tools v0.3.1
)
require (

Loading…
Cancel
Save