Documentation
¶
Overview ¶
client/cache/cache.go
Index ¶
- func CacheUserDataFromObjects(publicKey string, metadata *nostr.Event, mailboxes *core.Mailboxes)
- func CleanupExpired()
- func ClearUserData(publicKey string)
- func GetCacheExpiry() time.Duration
- func GetCacheStats() map[string]interface{}
- func GetParsedUserData(publicKey string) (*nostr.Event, *core.Mailboxes, bool)
- func IsExpiringSoon(publicKey string, within time.Duration) bool
- func IsValidCachedData(cachedData CachedUserData) bool
- func SetCacheExpiry(duration time.Duration)
- func SetUserData(publicKey string, metadata, mailboxes string)
- func StartCacheCleanup()
- type CachedUserData
- type UserCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheUserDataFromObjects ¶
CacheUserDataFromObjects caches user metadata and mailboxes from Go objects
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 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 SetCacheExpiry ¶
SetCacheExpiry allows dynamic configuration of cache expiry
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 serialized metadata (kind 0 event)
Mailboxes string // JSON serialized mailboxes (kind 10002 relay list)
Timestamp time.Time // 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 Useful for determining if refresh is needed soon