Struct deadpool_postgres::StatementCache
source · [−]pub struct StatementCache { /* private fields */ }Expand description
Representation of a cache of Statements.
StatementCache is bound to one Client, and Statements generated
by that Client must not be used with other Clients.
It can be used like that:
let client = pool.get().await?;
let stmt = client
.statement_cache
.prepare(&client, "SELECT 1")
.await;
let rows = client.query(stmt, &[]).await?;
...Normally, you probably want to use the ClientWrapper::prepare_cached()
and ClientWrapper::prepare_typed_cached() methods instead (or the
similar ones on Transaction).
Implementations
sourceimpl StatementCache
impl StatementCache
sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns current size of this StatementCache.
sourcepub fn clear(&self)
pub fn clear(&self)
Clears this StatementCache.
Important: This only clears the StatementCache of one Client
instance. If you want to clear the StatementCache of all Clients
you should be calling pool.manager().statement_caches.clear() instead.
sourcepub fn remove(&self, query: &str, types: &[Type]) -> Option<Statement>
pub fn remove(&self, query: &str, types: &[Type]) -> Option<Statement>
Removes a Statement from this StatementCache.
Important: This only removes a Statement from one Client
cache. If you want to remove a Statement from all
StatementCaches you should be calling
pool.manager().statement_caches.remove() instead.
sourcepub async fn prepare(
&self,
client: &PgClient,
query: &str
) -> Result<Statement, Error>
pub async fn prepare(
&self,
client: &PgClient,
query: &str
) -> Result<Statement, Error>
Creates a new prepared Statement using this StatementCache, if
possible.
Auto Trait Implementations
impl RefUnwindSafe for StatementCache
impl Send for StatementCache
impl Sync for StatementCache
impl Unpin for StatementCache
impl UnwindSafe for StatementCache
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more