From 1ef7308d37a19fa8bb9792bec7df3627d998440d Mon Sep 17 00:00:00 2001 From: qydysky Date: Fri, 26 May 2023 02:30:28 +0800 Subject: [PATCH] add --- sync/Map.go | 4 ++-- web/Web.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sync/Map.go b/sync/Map.go index b74cef1..1fe1bde 100644 --- a/sync/Map.go +++ b/sync/Map.go @@ -72,9 +72,9 @@ type mapExceededItem[V any] struct { exceeded time.Time } -func (t *MapExceeded[K, V]) Store(k K, v V, dur time.Duration) { +func (t *MapExceeded[K, V]) Store(k K, v *V, dur time.Duration) { t.m.Store(k, mapExceededItem[V]{ - data: &v, + data: v, exceeded: time.Now().Add(dur), }) } diff --git a/web/Web.go b/web/Web.go index 919d3a0..ff168a2 100644 --- a/web/Web.go +++ b/web/Web.go @@ -233,7 +233,7 @@ func (t *Cache) IsCache(key string) (res *[]byte, isCache bool) { return t.g.Load(key) } -func (t *Cache) Store(key string, aliveDur time.Duration, data []byte) { +func (t *Cache) Store(key string, aliveDur time.Duration, data *[]byte) { t.g.Store(key, data, aliveDur) if s := int64(t.g.Len()); s > 10 && t.gcL.Load() <= s { t.gcL.Store(s * 2) -- 2.39.2