Skip to content

Commit

Permalink
sdk: mutelist cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Nov 27, 2024
1 parent c5c9bba commit 1ac5516
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/mutes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import "context"
type MuteList = GenericList[Follow]

func (sys *System) FetchMuteList(ctx context.Context, pubkey string) MuteList {
ml, _ := fetchGenericList[Follow](sys, ctx, pubkey, 10000, parseFollow, nil, false)
ml, _ := fetchGenericList(sys, ctx, pubkey, 10000, parseFollow, sys.MuteListCache, false)
return ml
}
8 changes: 8 additions & 0 deletions sdk/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
type System struct {
RelayListCache cache.Cache32[RelayList]
FollowListCache cache.Cache32[FollowList]
MuteListCache cache.Cache32[FollowList]
MetadataCache cache.Cache32[ProfileMetadata]
Hints hints.HintsDB
Pool *nostr.SimplePool
Expand Down Expand Up @@ -54,6 +55,7 @@ func NewSystem(mods ...SystemModifier) *System {
sys := &System{
RelayListCache: cache_memory.New32[RelayList](1000),
FollowListCache: cache_memory.New32[FollowList](1000),
MuteListCache: cache_memory.New32[FollowList](1000),
MetadataCache: cache_memory.New32[ProfileMetadata](1000),
RelayListRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"),
FollowListRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"),
Expand Down Expand Up @@ -173,6 +175,12 @@ func WithFollowListCache(cache cache.Cache32[FollowList]) SystemModifier {
}
}

func WithMuteListCache(cache cache.Cache32[FollowList]) SystemModifier {
return func(sys *System) {
sys.MuteListCache = cache
}
}

func WithMetadataCache(cache cache.Cache32[ProfileMetadata]) SystemModifier {
return func(sys *System) {
sys.MetadataCache = cache
Expand Down

0 comments on commit 1ac5516

Please sign in to comment.