Documentation
¶
Index ¶
- Variables
- func GetTTL(cacheType CacheType, cacheKey string) time.Duration
- func HashString(s string) string
- type CacheEntry
- type CacheManager
- func (c *CacheManager) Get(ctx context.Context, userID int32, cacheType CacheType, cacheKey string) (*CacheEntry, error)
- func (c *CacheManager) InvalidateAll(ctx context.Context, userID int32) error
- func (c *CacheManager) InvalidateByType(ctx context.Context, userID int32, cacheType CacheType) error
- func (c *CacheManager) IsValid(entry *CacheEntry, currentPromptHash, currentDataHash string) bool
- func (c *CacheManager) Set(ctx context.Context, userID int32, cacheType CacheType, ...) error
- type CacheType
- type PresenceManager
- func (p *PresenceManager) Cleanup(ctx context.Context) error
- func (p *PresenceManager) GetLastPing(ctx context.Context, userID int32) (*time.Time, error)
- func (p *PresenceManager) IsOnline(ctx context.Context, userID int32) (bool, error)
- func (p *PresenceManager) Ping(ctx context.Context, userID int32) error
Constants ¶
This section is empty.
Variables ¶
View Source
var RefreshIntervals = map[string]time.Duration{ "profile_day": 4 * time.Hour, "profile_week": 3 * 24 * time.Hour, "profile_month": 7 * 24 * time.Hour, "profile_year": 7 * 24 * time.Hour, "profile_all_time": 7 * 24 * time.Hour, "playlist": 7 * 24 * time.Hour, "nowplaying": 365 * 24 * time.Hour, }
RefreshIntervals for different cache types and periods
Functions ¶
Types ¶
type CacheEntry ¶
type CacheEntry struct {
ID int32
UserID int32
CacheType string
CacheKey string
PromptHash string
DataHash string
Response string
CreatedAt time.Time
ExpiresAt time.Time
ListenCount int32
}
CacheEntry represents a cached AI response
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager handles AI cache operations
func NewCacheManager ¶
func NewCacheManager(pool *pgxpool.Pool) *CacheManager
NewCacheManager creates a new cache manager
func (*CacheManager) Get ¶
func (c *CacheManager) Get(ctx context.Context, userID int32, cacheType CacheType, cacheKey string) (*CacheEntry, error)
Get retrieves a cache entry if valid
func (*CacheManager) InvalidateAll ¶
func (c *CacheManager) InvalidateAll(ctx context.Context, userID int32) error
InvalidateAll clears all AI caches for a user
func (*CacheManager) InvalidateByType ¶
func (c *CacheManager) InvalidateByType(ctx context.Context, userID int32, cacheType CacheType) error
InvalidateByType clears all caches of a specific type for a user
func (*CacheManager) IsValid ¶
func (c *CacheManager) IsValid(entry *CacheEntry, currentPromptHash, currentDataHash string) bool
IsValid checks if cache entry is still valid based on prompt, data, and expiration
type PresenceManager ¶
type PresenceManager struct {
// contains filtered or unexported fields
}
PresenceManager tracks active user sessions
func NewPresenceManager ¶
func NewPresenceManager(pool *pgxpool.Pool) *PresenceManager
NewPresenceManager creates a new presence manager
func (*PresenceManager) Cleanup ¶
func (p *PresenceManager) Cleanup(ctx context.Context) error
Cleanup removes old presence records (older than 5 minutes)
func (*PresenceManager) GetLastPing ¶
GetLastPing returns when the user was last active
Click to show internal directories.
Click to hide internal directories.