Skip to content

Commit 588fdd3

Browse files
committed
feat: add PurgeCache function to remove dead connections from cache
1 parent 1aac158 commit 588fdd3

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

core/dbio/connection/connection.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,13 @@ func CloseAll() {
10971097
}
10981098
}
10991099

1100+
// PurgeCache removes a connection from the cache by hash so the next
1101+
// AsDatabaseContext / AsFileContext / AsAPIContext call rebuilds it.
1102+
// Use this after detecting a dead underlying handle (e.g. "sql: database is closed").
1103+
func PurgeCache(hash string) {
1104+
connCache.Remove(hash)
1105+
}
1106+
11001107
// CopyDirect copies directly from cloud files
11011108
// (without passing through dbio)
11021109
func CopyDirect(conn database.Connection, tableFName string, srcFile Connection) (cnt uint64, ok bool, err error) {

0 commit comments

Comments
 (0)