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

Returns current size of this StatementCache.

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.

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.

Creates a new prepared Statement using this StatementCache, if possible.

See tokio_postgres::Client::prepare().

Creates a new prepared Statement with specifying its Types explicitly using this StatementCache, if possible.

See tokio_postgres::Client::prepare_typed().

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.