From 749eb118307c5a2dd190c1855f68cb61dfdf06ef Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Fri, 12 Jan 2024 18:23:15 +0800 Subject: [PATCH] feat: local cache --- pkg/localcache/local/lru.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/pkg/localcache/local/lru.go b/pkg/localcache/local/lru.go index 45dc3b651..5ce0f1cc4 100644 --- a/pkg/localcache/local/lru.go +++ b/pkg/localcache/local/lru.go @@ -6,10 +6,32 @@ import ( "time" ) +type LRU1[K comparable, V any] interface { + Get(key K, fetch func() (V, error)) (V, error) + Del(key K) bool + Stop() +} + +//type expirableLRU[K comparable, V any] struct { +// core expirable.LRU[K, V] +//} +// +//func (x *expirableLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) { +// +// return x.core.Get(key, fetch) +//} +// +//func (x *expirableLRU[K, V]) Del(key K) bool { +// return x.core.Remove(key) +//} +// +//func (x *expirableLRU[K, V]) Stop() { +// +//} + type waitItem[V any] struct { lock sync.Mutex expires int64 - active bool err error value V } @@ -80,3 +102,7 @@ func (x *LRU[K, V]) Del(key K) bool { x.lock.Unlock() return ok } + +func (x *LRU[K, V]) Stop() { + +}