sdk: only instantiate caches by default when they are necessary.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
cache_memory "github.com/nbd-wtf/go-nostr/sdk/cache/memory"
|
||||
)
|
||||
|
||||
type EventRef struct{ nostr.Pointer }
|
||||
@@ -13,11 +14,19 @@ type EventRef struct{ nostr.Pointer }
|
||||
func (e EventRef) Value() string { return e.Pointer.AsTagReference() }
|
||||
|
||||
func (sys *System) FetchBookmarkList(ctx context.Context, pubkey string) GenericList[EventRef] {
|
||||
if sys.BookmarkListCache == nil {
|
||||
sys.BookmarkListCache = cache_memory.New32[GenericList[EventRef]](1000)
|
||||
}
|
||||
|
||||
ml, _ := fetchGenericList(sys, ctx, pubkey, 10003, kind_10003, parseEventRef, sys.BookmarkListCache)
|
||||
return ml
|
||||
}
|
||||
|
||||
func (sys *System) FetchPinList(ctx context.Context, pubkey string) GenericList[EventRef] {
|
||||
if sys.PinListCache == nil {
|
||||
sys.PinListCache = cache_memory.New32[GenericList[EventRef]](1000)
|
||||
}
|
||||
|
||||
ml, _ := fetchGenericList(sys, ctx, pubkey, 10001, kind_10001, parseEventRef, sys.PinListCache)
|
||||
return ml
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user