Clear removes and closes all the currently cached prepared statements
()
| 80 | |
| 81 | // Clear removes and closes all the currently cached prepared statements |
| 82 | func (sc *StmtCache) Clear() (err error) { |
| 83 | sc.mu.Lock() |
| 84 | defer sc.mu.Unlock() |
| 85 | |
| 86 | for key, stmt := range sc.cache { |
| 87 | delete(sc.cache, key) |
| 88 | |
| 89 | if stmt == nil { |
| 90 | continue |
| 91 | } |
| 92 | |
| 93 | if cerr := stmt.Close(); cerr != nil { |
| 94 | err = cerr |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | if err != nil { |
| 99 | return fmt.Errorf("one or more Stmt.Close failed; last error: %v", err) |
| 100 | } |
| 101 | |
| 102 | return |
| 103 | } |
| 104 | |
| 105 | type DBProxyBeginner interface { |
| 106 | DBProxy |
no outgoing calls