Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(store): remove databaseGroupCache (#18481)
Danny Xua9482c569a69
diff --git a/backend/store/database_group.go b/backend/store/database_group.goindex 2af72d5cc7..021010c2f1 100644--- a/backend/store/database_group.go+++ b/backend/store/database_group.go@@ -51,7 +51,6 @@ func (s *Store) DeleteDatabaseGroup(ctx context.Context, projectID, resourceID sif err := tx.Commit(); err != nil {return errors.Wrapf(err, "failed to commit transaction")}- s.databaseGroupCache.Remove(getDatabaseGroupCacheKey(projectID, resourceID))return nil}@@ -119,20 +118,12 @@ func (s *Store) ListDatabaseGroups(ctx context.Context, find *FindDatabaseGroupMif err := tx.Commit(); err != nil {return nil, errors.Wrapf(err, "failed to commit transaction")}- for _, databaseGroup := range databaseGroups {- s.databaseGroupCache.Add(getDatabaseGroupCacheKey(databaseGroup.ProjectID, databaseGroup.ResourceID), databaseGroup)- }return databaseGroups, nil}// GetDatabaseGroup gets a database group.func (s *Store) GetDatabaseGroup(ctx context.Context, find *FindDatabaseGroupMessage) (*DatabaseGroupMessage, error) {- if find.ProjectID != nil && find.ResourceID != nil {- if v, ok := s.databaseGroupCache.Get(getDatabaseGroupCacheKey(*find.ProjectID, *find.ResourceID)); ok && s.enableCache {- return v, nil- }- }tx, err := s.GetDB().BeginTx(ctx, &sql.TxOptions{ReadOnly: true})if err != nil {return nil, err@@ -154,7 +145,6 @@ func (s *Store) GetDatabaseGroup(ctx context.Context, find *FindDatabaseGroupMesif len(databaseGroups) > 1 {return nil, errors.Errorf("found multiple database groups")}- s.databaseGroupCache.Add(getDatabaseGroupCacheKey(databaseGroups[0].ProjectID, databaseGroups[0].ResourceID), databaseGroups[0])return databaseGroups[0], nil}@@ -209,7 +199,6 @@ func (s *Store) UpdateDatabaseGroup(ctx context.Context, projectID, resourceID sreturn nil, errors.Wrapf(err, "failed to unmarshal expression")}updatedDatabaseGroup.Expression = &expression- s.databaseGroupCache.Add(getDatabaseGroupCacheKey(updatedDatabaseGroup.ProjectID, updatedDatabaseGroup.ResourceID), &updatedDatabaseGroup)return &updatedDatabaseGroup, nil}@@ -247,6 +236,5 @@ func (s *Store) CreateDatabaseGroup(ctx context.Context, create *DatabaseGroupMereturn nil, errors.Wrapf(err, "failed to commit transaction")}- s.databaseGroupCache.Add(getDatabaseGroupCacheKey(create.ProjectID, create.ResourceID), create)return create, nil}diff --git a/backend/store/store.go b/backend/store/store.goindex b60acb3850..65449987b4 100644--- a/backend/store/store.go+++ b/backend/store/store.go@@ -28,7 +28,6 @@ type Store struct {issueByPipelineCache *lru.Cache[int, *IssueMessage]pipelineCache *lru.Cache[int, *PipelineMessage]settingCache *lru.Cache[storepb.SettingName, *SettingMessage]- databaseGroupCache *lru.Cache[string, *DatabaseGroupMessage]rolesCache *lru.Cache[string, *RoleMessage]groupCache *lru.Cache[string, *GroupMessage]sheetCache *lru.Cache[int, *SheetMessage]@@ -85,10 +84,6 @@ func New(ctx context.Context, pgURL string, enableCache bool) (*Store, error) {if err != nil {return nil, err}- databaseGroupCache, err := lru.New[string, *DatabaseGroupMessage](1024)- if err != nil {- return nil, err- }sheetStatementCache, err := lru.New[int, string](10)if err != nil {return nil, err@@ -124,7 +119,6 @@ func New(ctx context.Context, pgURL string, enableCache bool) (*Store, error) {settingCache: settingCache,rolesCache: rolesCache,sheetCache: sheetCache,- databaseGroupCache: databaseGroupCache,sheetStatementCache: sheetStatementCache,dbMetadataCache: dbMetadataCache,groupCache: groupCache,@@ -160,7 +154,3 @@ func getPolicyCacheKey(resourceType storepb.Policy_Resource, resource string, pofunc getDatabaseCacheKey(instanceID, databaseName string) string {return fmt.Sprintf("%s/%s", instanceID, databaseName)}--func getDatabaseGroupCacheKey(projectID, resourceID string) string {- return fmt.Sprintf("%s/%s", projectID, resourceID)-}