Documentation
¶
Index ¶
- func AddClientRelay(publicKey, relayURL string) error
- func AddClientRelayWithPermissions(publicKey, relayURL string, read, write bool) error
- func CacheUserDataFromObjects(publicKey string, metadata *nostr.Event, mailboxes *core.Mailboxes)
- func CleanupExpired()
- func ClearClientRelays(publicKey string)
- func ClearUserData(publicKey string)
- func GetCacheExpiry() time.Duration
- func GetCacheStats() map[string]interface{}
- func GetClientRelays(publicKey string) []string
- func GetParsedUserData(publicKey string) (*nostr.Event, *core.Mailboxes, bool)
- func IsExpiringSoon(publicKey string, within time.Duration) bool
- func IsValidCachedData(cachedData CachedUserData) bool
- func RemoveClientRelay(publicKey, relayURL string) error
- func SetCacheExpiry(duration time.Duration)
- func SetUserClientRelaysFromMailboxes(publicKey string) error
- func SetUserData(publicKey string, metadata, mailboxes string)
- func StartCacheCleanup()
- type CachedUserData
- type ClientRelayConfig
- type UserCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClientRelay ¶ added in v0.4.12
Legacy function for backward compatibility
func AddClientRelayWithPermissions ¶ added in v0.4.12
AddClientRelayWithPermissions adds a client relay with specific permissions
func CacheUserDataFromObjects ¶
CacheUserDataFromObjects caches user metadata and mailboxes from Go objects
func ClearClientRelays ¶ added in v0.4.12
func ClearClientRelays(publicKey string)
ClearClientRelays clears all client relays for a user
func ClearUserData ¶
func ClearUserData(publicKey string)
ClearUserData removes a specific user from cache
func GetCacheExpiry ¶
GetCacheExpiry returns the current cache expiry duration
func GetCacheStats ¶
func GetCacheStats() map[string]interface{}
GetCacheStats returns statistics about the cache
func GetClientRelays ¶ added in v0.4.12
GetClientRelays returns user's cached client relays (legacy format)
func GetParsedUserData ¶
GetParsedUserData retrieves and parses cached user data
func IsExpiringSoon ¶
IsExpiringSoon checks if cache will expire within the given duration
func IsValidCachedData ¶
func IsValidCachedData(cachedData CachedUserData) bool
IsValidCachedData checks if cached data contains valid user information
func RemoveClientRelay ¶ added in v0.4.12
RemoveClientRelay removes a specific relay from user's client relay list
func SetCacheExpiry ¶
SetCacheExpiry allows dynamic configuration of cache expiry
func SetUserClientRelaysFromMailboxes ¶ added in v0.4.12
SetUserClientRelaysFromMailboxes sets user's client relays from cached mailbox data
func SetUserData ¶
SetUserData stores user metadata and mailbox data in cache
func StartCacheCleanup ¶
func StartCacheCleanup()
startCacheCleanup starts a background goroutine to clean up expired cache entries
Types ¶
type CachedUserData ¶
type CachedUserData struct {
Metadata string `json:"metadata"` // JSON serialized metadata (kind 0 event)
Mailboxes string `json:"mailboxes"` // JSON serialized mailboxes (kind 10002 relay list)
Timestamp time.Time `json:"timestamp"` // Time of insertion for expiration
}
CachedUserData holds user metadata and mailbox information
func GetUserData ¶
func GetUserData(publicKey string) (CachedUserData, bool)
GetUserData retrieves cached user data if not expired
func GetUserDataWithAge ¶
func GetUserDataWithAge(publicKey string) (CachedUserData, time.Duration, bool)
GetUserDataWithAge retrieves cached user data with age information
type ClientRelayConfig ¶ added in v0.4.12
type ClientRelayConfig struct {
URL string `json:"url"`
Read bool `json:"read"`
Write bool `json:"write"`
Connected bool `json:"connected"` // Whether the client is connected to this relay
AddedAt time.Time `json:"added_at"` // Time when the relay was added
}
ClientRelayConfig represents relay configuration with permissions
func GetUserClientRelays ¶ added in v0.4.12
func GetUserClientRelays(publicKey string) ([]ClientRelayConfig, error)
GetUserClientRelays returns user's client relays in the format expected by the API
func GetUserClientRelaysWithPermissions ¶ added in v0.4.12
func GetUserClientRelaysWithPermissions(publicKey string) ([]ClientRelayConfig, error)
GetUserClientRelaysWithPermissions retrieves user's client relays with permissions