Struct deadpool_postgres::StatementCache[][src]

pub struct StatementCache { /* fields omitted */ }
Expand description

This structure provides access to the statement cache. The statement cache is bound to one client and statements generated by one 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 `prepare_cached`
and `prepare_typed_cached` methods from the `ClientWrapper`
and `Transaction` structs instead.

Implementations

impl StatementCache[src]

pub fn size(&self) -> usize[src]

Retrieve current size of the cache

pub fn clear(&self)[src]

Clear cache

Important: This only clears the statement cache of one client instance. If you want to clear the statement cache of all clients you should be calling pool.manager().statement_caches.clear() instead.

pub fn remove(&self, query: &str, types: &[Type]) -> Option<Statement>[src]

Remove statement from cache

Important: This only removes the statement from one client cache. If you want to remove a statement from all statement caches you should be calling pool.manager().statement_caches.remove() instead.

pub async fn prepare(
    &self,
    client: &PgClient,
    query: &str
) -> Result<Statement, Error>
[src]

Creates a new prepared statement using the statement cache if possible.

See tokio_postgres::Client::prepare

pub async fn prepare_typed(
    &self,
    client: &PgClient,
    query: &str,
    types: &[Type]
) -> Result<Statement, Error>
[src]

Creates a new prepared statement using the statement cache if possible.

See tokio_postgres::Client::prepare_typed

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V