Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to clear DB cache #4

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sqlutils/sqlutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ func GetDB(mysql_uri string) (*sql.DB, bool, error) {
return knownDBs[mysql_uri], exists, nil
}

// Resets the knownDBs cache, used when the DB connections have been closed,
// and new connections are needed to access the DB
func ResetDBCache() {
knownDBsMutex.Lock()
defer func() {
knownDBsMutex.Unlock()
}()

knownDBs = make(map[string]*sql.DB)
}

// RowToArray is a convenience function, typically not called directly, which maps a
// single read database row into a NullString
func RowToArray(rows *sql.Rows, columns []string) []CellData {
Expand Down