pub struct CachingSession<S = RandomState>where
S: Clone + BuildHasher,{ /* private fields */ }
Expand description
Provides auto caching while executing queries
Implementations§
Source§impl<S> CachingSession<S>
impl<S> CachingSession<S>
Source§impl<S> CachingSession<S>where
S: BuildHasher + Clone,
impl<S> CachingSession<S>where
S: BuildHasher + Clone,
Sourcepub fn with_hasher(session: Session, cache_size: usize, hasher: S) -> Self
pub fn with_hasher(session: Session, cache_size: usize, hasher: S) -> Self
Builds a CachingSession
from a Session
, a cache size, and a BuildHasher
.,
using a customer hasher.
Sourcepub async fn execute(
&self,
query: impl Into<Query>,
values: impl SerializeRow,
) -> Result<QueryResult, QueryError>
pub async fn execute( &self, query: impl Into<Query>, values: impl SerializeRow, ) -> Result<QueryResult, QueryError>
Does the same thing as Session::execute
but uses the prepared statement cache
Sourcepub async fn execute_iter(
&self,
query: impl Into<Query>,
values: impl SerializeRow,
) -> Result<RowIterator, QueryError>
pub async fn execute_iter( &self, query: impl Into<Query>, values: impl SerializeRow, ) -> Result<RowIterator, QueryError>
Does the same thing as Session::execute_iter
but uses the prepared statement cache
Sourcepub async fn execute_paged(
&self,
query: impl Into<Query>,
values: impl SerializeRow,
paging_state: Option<Bytes>,
) -> Result<QueryResult, QueryError>
pub async fn execute_paged( &self, query: impl Into<Query>, values: impl SerializeRow, paging_state: Option<Bytes>, ) -> Result<QueryResult, QueryError>
Does the same thing as Session::execute_paged
but uses the prepared statement cache
Sourcepub async fn batch(
&self,
batch: &Batch,
values: impl BatchValues,
) -> Result<QueryResult, QueryError>
pub async fn batch( &self, batch: &Batch, values: impl BatchValues, ) -> Result<QueryResult, QueryError>
Does the same thing as Session::batch
but uses the prepared statement cache
Prepares batch using CachingSession::prepare_batch if needed and then executes it
Sourcepub async fn prepare_batch(&self, batch: &Batch) -> Result<Batch, QueryError>
pub async fn prepare_batch(&self, batch: &Batch) -> Result<Batch, QueryError>
Prepares all statements within the batch and returns a new batch where every statement is prepared. Uses the prepared statements cache.
Sourcepub async fn add_prepared_statement(
&self,
query: impl Into<&Query>,
) -> Result<PreparedStatement, QueryError>
pub async fn add_prepared_statement( &self, query: impl Into<&Query>, ) -> Result<PreparedStatement, QueryError>
Adds a prepared statement to the cache
pub fn get_max_capacity(&self) -> usize
pub fn get_session(&self) -> &Session
Trait Implementations§
Auto Trait Implementations§
impl<S = RandomState> !Freeze for CachingSession<S>
impl<S = RandomState> !RefUnwindSafe for CachingSession<S>
impl<S> Send for CachingSession<S>where
S: Send,
impl<S> Sync for CachingSession<S>
impl<S> Unpin for CachingSession<S>where
S: Unpin,
impl<S = RandomState> !UnwindSafe for CachingSession<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more