GODT-1349: Change cache-related settings when enabling/disabling/moving cache

This commit is contained in:
James Houlahan
2021-09-16 20:22:16 +02:00
committed by Jakub
parent 18257f0302
commit 29af8e7178
3 changed files with 45 additions and 18 deletions

View File

@ -434,6 +434,18 @@ func (u *Users) EnableCache() error {
return nil
}
func (u *Users) DisableCache() error {
// NOTE(GODT-1158): Is it an error if we can't remove a user's cache?
for _, user := range u.users {
if err := user.store.RemoveCache(); err != nil {
logrus.WithError(err).Error("Failed to remove user's message cache")
}
}
return nil
}
func (u *Users) MigrateCache(from, to string) error {
// NOTE(GODT-1158): Is it enough to just close the store? Do we need to force-close the cacher too?
@ -451,18 +463,6 @@ func (u *Users) MigrateCache(from, to string) error {
return os.Rename(from, to)
}
func (u *Users) DisableCache() error {
// NOTE(GODT-1158): Is it an error if we can't remove a user's cache?
for _, user := range u.users {
if err := user.store.RemoveCache(); err != nil {
logrus.WithError(err).Error("Failed to remove user's message cache")
}
}
return nil
}
// hasUser returns whether the struct currently has a user with ID `id`.
func (u *Users) hasUser(id string) (user *User, ok bool) {
for _, u := range u.users {