mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-19 10:36:42 +01:00
sdk: only instantiate caches by default when they are necessary.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
cache_memory "github.com/nbd-wtf/go-nostr/sdk/cache/memory"
|
||||
)
|
||||
|
||||
type Topic string
|
||||
@@ -11,11 +12,19 @@ type Topic string
|
||||
func (r Topic) Value() string { return string(r) }
|
||||
|
||||
func (sys *System) FetchTopicList(ctx context.Context, pubkey string) GenericList[Topic] {
|
||||
if sys.TopicListCache == nil {
|
||||
sys.TopicListCache = cache_memory.New32[GenericList[Topic]](1000)
|
||||
}
|
||||
|
||||
ml, _ := fetchGenericList(sys, ctx, pubkey, 10015, kind_10015, parseTopicString, sys.TopicListCache)
|
||||
return ml
|
||||
}
|
||||
|
||||
func (sys *System) FetchTopicSets(ctx context.Context, pubkey string) GenericSets[Topic] {
|
||||
if sys.TopicSetsCache == nil {
|
||||
sys.TopicSetsCache = cache_memory.New32[GenericSets[Topic]](1000)
|
||||
}
|
||||
|
||||
ml, _ := fetchGenericSets(sys, ctx, pubkey, 30015, kind_30015, parseTopicString, sys.TopicSetsCache)
|
||||
return ml
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user