From: qydysky Date: Thu, 25 May 2023 18:30:28 +0000 (+0800) Subject: add X-Git-Tag: v0.27.14~1 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=1ef7308d37a19fa8bb9792bec7df3627d998440d;p=part%2F.git add --- 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)