From 6755b37199df6c7d497583d950b4128a52d0c0b7 Mon Sep 17 00:00:00 2001 From: Caj Larsson Date: Mon, 9 Jan 2023 15:19:16 +0800 Subject: [PATCH] Rename package --- cache_test.go | 2 +- examples/main.go | 7 ++++--- go.mod | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cache_test.go b/cache_test.go index b93030c..f544cdc 100644 --- a/cache_test.go +++ b/cache_test.go @@ -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") diff --git a/examples/main.go b/examples/main.go index b801fe4..f3e39ca 100644 --- a/examples/main.go +++ b/examples/main.go @@ -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) diff --git a/go.mod b/go.mod index c49442f..5e47fd3 100644 --- a/go.mod +++ b/go.mod @@ -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 (