sdk: mutelist cache.

This commit is contained in:
fiatjaf
2024-11-27 00:59:34 -03:00
parent c5c9bba586
commit 1ac5516440
2 changed files with 9 additions and 1 deletions

View File

@@ -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
@@ -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"),
@@ -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