bluesky viewer in the terminal
at main 1.3 kB view raw
1package store 2 3import "time" 4 5// PostRateCacheModel represents a cached post rate computation for an actor. 6// Stores expensive post rate calculations with TTL support (24 hours default). 7type PostRateCacheModel struct { 8 ActorDid string 9 PostsPerDay float64 10 LastPostDate time.Time 11 SampleSize int 12 FetchedAt time.Time 13 ExpiresAt time.Time 14} 15 16// IsFresh returns true if the cached post rate has not expired. 17// Post rates expire after 24 hours by default. 18func (m *PostRateCacheModel) IsFresh() bool { 19 return time.Now().Before(m.ExpiresAt) 20} 21 22// ActivityCacheModel represents cached activity data (last post date) for an actor. 23// Stores last post date lookups with TTL support (24 hours default). 24type ActivityCacheModel struct { 25 ActorDid string 26 LastPostDate time.Time // May be zero if actor has never posted 27 FetchedAt time.Time 28 ExpiresAt time.Time 29} 30 31// IsFresh returns true if the cached activity data has not expired. 32// Activity data expires after 24 hours by default. 33func (m *ActivityCacheModel) IsFresh() bool { 34 return time.Now().Before(m.ExpiresAt) 35} 36 37// HasPosted returns true if the actor has posted at least once. 38// A zero LastPostDate indicates the actor has never posted. 39func (m *ActivityCacheModel) HasPosted() bool { 40 return !m.LastPostDate.IsZero() 41}