MCPcopy Index your code
hub / github.com/bytebase/bytebase / removeDatabaseCache

Method removeDatabaseCache

backend/store/database.go:85–97  ·  view source on GitHub ↗

removeDatabaseCache invalidates both workspace-scoped and unscoped cache entries for a database.

(ctx context.Context, instanceID, databaseName string)

Source from the content-addressed store, hash-verified

83
84// removeDatabaseCache invalidates both workspace-scoped and unscoped cache entries for a database.
85func (s *Store) removeDatabaseCache(ctx context.Context, instanceID, databaseName string) {
86 // Remove unscoped (runner) cache entry.
87 s.databaseCache.Remove(getDatabaseCacheKey("", instanceID, databaseName))
88 // Remove workspace-scoped (API) cache entry.
89 // Query workspace directly from instance table to avoid workspace-filtering issues with GetInstance.
90 var workspace string
91 if err := s.GetDB().QueryRowContext(ctx,
92 "SELECT workspace FROM instance WHERE resource_id = $1", instanceID,
93 ).Scan(&workspace); err != nil {
94 return
95 }
96 s.databaseCache.Remove(getDatabaseCacheKey(workspace, instanceID, databaseName))
97}
98
99// GetDatabase gets a database.
100func (s *Store) GetDatabase(ctx context.Context, find *FindDatabaseMessage) (*DatabaseMessage, error) {

Callers 4

CreateDatabaseDefaultMethod · 0.95
UpsertDatabaseMethod · 0.95
UpdateDatabaseMethod · 0.95
BatchUpdateDatabasesMethod · 0.95

Calls 3

GetDBMethod · 0.95
getDatabaseCacheKeyFunction · 0.85
ScanMethod · 0.80

Tested by

no test coverage detected