aboutsummaryrefslogtreecommitdiff
path: root/backend/fetchers/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/fetchers/cache.go')
-rw-r--r--backend/fetchers/cache.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/backend/fetchers/cache.go b/backend/fetchers/cache.go
index b863d60..01c37fe 100644
--- a/backend/fetchers/cache.go
+++ b/backend/fetchers/cache.go
@@ -1,7 +1,6 @@
package fetchers
import (
- "llostre/backend/general"
"llostre/backend/notes"
"sync"
"time"
@@ -14,14 +13,14 @@ type CacheEntry struct {
type Cache struct {
posts map[string]*CacheEntry
- profiles map[string]*ProfileCacheEntry
+ profiles map[string]*AuthorCacheEntry
mu sync.RWMutex
}
func NewCache() *Cache {
return &Cache{
posts: make(map[string]*CacheEntry),
- profiles: make(map[string]*ProfileCacheEntry),
+ profiles: make(map[string]*AuthorCacheEntry),
}
}
@@ -77,12 +76,12 @@ func (c *Cache) GetMany(uris []string) map[string]*notes.Note {
return result
}
-type ProfileCacheEntry struct {
- Profile *general.Profile
+type AuthorCacheEntry struct {
+ Author *notes.Author
ExpiresAt time.Time
}
-func (c *Cache) GetProfile(did string) (*general.Profile, bool) {
+func (c *Cache) GetProfile(did string) (*notes.Author, bool) {
c.mu.Lock()
defer c.mu.Unlock()
@@ -96,15 +95,15 @@ func (c *Cache) GetProfile(did string) (*general.Profile, bool) {
return nil, false
}
- return entry.Profile, true
+ return entry.Author, true
}
-func (c *Cache) SetProfile(did string, profile *general.Profile) {
+func (c *Cache) SetAuthor(did string, author *notes.Author) {
c.mu.Lock()
defer c.mu.Unlock()
- c.profiles[did] = &ProfileCacheEntry{
- Profile: profile,
+ c.profiles[did] = &AuthorCacheEntry{
+ Author: author,
ExpiresAt: time.Now().Add(15 * time.Minute),
}
}