feat: local cache

This commit is contained in:
withchao 2024-01-12 18:23:15 +08:00
parent a81bc3fc23
commit 749eb11830

View File

@ -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() {
}