removeDatabaseCache invalidates both workspace-scoped and unscoped cache entries for a database.
(ctx context.Context, instanceID, databaseName string)
| 83 | |
| 84 | // removeDatabaseCache invalidates both workspace-scoped and unscoped cache entries for a database. |
| 85 | func (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. |
| 100 | func (s *Store) GetDatabase(ctx context.Context, find *FindDatabaseMessage) (*DatabaseMessage, error) { |
no test coverage detected