]> 127.0.0.1 Git - part/.git/commitdiff
add
authorqydysky <qydysky@foxmail.com>
Thu, 25 May 2023 18:30:28 +0000 (02:30 +0800)
committerqydysky <qydysky@foxmail.com>
Thu, 25 May 2023 18:30:28 +0000 (02:30 +0800)
sync/Map.go
web/Web.go

index b74cef136f82a1e82739e5f555635aa723fa2446..1fe1bde60c291b61fc9a52b411f84b7ed25125c3 100644 (file)
@@ -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),
        })
 }
index 919d3a0bc6f896e876b2065f34647d89158f9435..ff168a2871c587d1b69a3767c5885840e6b5a531 100644 (file)
@@ -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)