Skip to content

Commit 21e4dd7

Browse files
authored
Merge pull request #754 from pleshevskiy/task-753
feat: add method to clear types cache
2 parents fc10985 + 558c169 commit 21e4dd7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tokio-postgres/src/client.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ impl InnerClient {
113113
self.state.lock().types.insert(oid, type_.clone());
114114
}
115115

116+
pub fn clear_types(&self) {
117+
self.state.lock().types.clear();
118+
}
119+
116120
pub fn with_buf<F, R>(&self, f: F) -> R
117121
where
118122
F: FnOnce(&mut BytesMut) -> R,
@@ -176,6 +180,11 @@ impl Client {
176180
&self.inner
177181
}
178182

183+
/// Clears the cache of database types (domain, enum, composition) that are loaded when preparing a query.
184+
pub fn clear_types_cache(&self) {
185+
self.inner().clear_types()
186+
}
187+
179188
#[cfg(feature = "runtime")]
180189
pub(crate) fn set_socket_config(&mut self, socket_config: SocketConfig) {
181190
self.socket_config = Some(socket_config);

0 commit comments

Comments
 (0)