clear in-memory image cache on server logout

This commit is contained in:
Drew Weymouth
2023-07-28 17:10:40 -07:00
parent 873dc16b0d
commit 09fcc6dcb8
2 changed files with 19 additions and 4 deletions
+7
View File
@@ -128,6 +128,13 @@ func (i *ImageCache) GetWithNewTTL(key string, newTtl time.Duration) (image.Imag
return nil, ErrNotFound
}
func (i *ImageCache) Clear() {
i.mu.Lock()
defer i.mu.Unlock()
i.cache = make(map[string]CacheItem)
}
// must be called when rwmutex is already acquired for writing
func (i *ImageCache) evictOne() {
now := time.Now().Unix()