Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: clear cache (#12903)

ecmadao92c554fcbc37
diff --git a/backend/store/principal.go b/backend/store/principal.go
index 3a4b67434f..022f051753 100644
--- a/backend/store/principal.go
+++ b/backend/store/principal.go
@@ -75,16 +75,12 @@ func (s *Store) GetUserByID(ctx context.Context, id int) (*UserMessage, error) {
return v, nil
}
- users, err := s.listAndCacheAllUsers(ctx)
- if err != nil {
+ if _, err := s.listAndCacheAllUsers(ctx); err != nil {
return nil, err
}
- for _, user := range users {
- if user.ID == id {
- return user, nil
- }
- }
- return nil, nil
+
+ user, _ := s.userIDCache.Get(id)
+ return user, nil
}
// GetUserByEmail gets the user by email.
@@ -93,16 +89,12 @@ func (s *Store) GetUserByEmail(ctx context.Context, email string) (*UserMessage,
return v, nil
}
- users, err := s.listAndCacheAllUsers(ctx)
- if err != nil {
+ if _, err := s.listAndCacheAllUsers(ctx); err != nil {
return nil, err
}
- for _, user := range users {
- if user.Email == email {
- return user, nil
- }
- }
- return nil, nil
+
+ user, _ := s.userEmailCache.Get(email)
+ return user, nil
}
// ListUsers list users.
diff --git a/backend/store/setting.go b/backend/store/setting.go
index 23a7f0b6ea..148a7734b3 100644
--- a/backend/store/setting.go
+++ b/backend/store/setting.go
@@ -207,6 +207,9 @@ func (s *Store) GetDataClassificationConfigByID(ctx context.Context, classificat
// DeleteCache deletes the cache.
func (s *Store) DeleteCache() {
s.settingCache.Purge()
+ s.policyCache.Purge()
+ s.userEmailCache.Purge()
+ s.userIDCache.Purge()
}
// GetSettingV2 returns the setting by name.