pub struct PreparedDbQuery<T, C = PostcardCodec>where
C: CacheCodec,{ /* private fields */ }Expand description
A prepared database query descriptor.
PreparedDbQuery keeps adapter state and stable query-cache metadata close
together. It can cheaply create ordinary DbQuery values for each call,
or execute loaders directly through load_id/fetch_with_id.
Implementations§
Source§impl<T, C> PreparedDbQuery<T, C>where
C: CacheCodec,
impl<T, C> PreparedDbQuery<T, C>where
C: CacheCodec,
Sourcepub fn cache(&self) -> &HydraCache<C>
pub fn cache(&self) -> &HydraCache<C>
Return the underlying local cache.
Sourcepub fn prepared_policy(&self) -> &PreparedQueryPolicy
pub fn prepared_policy(&self) -> &PreparedQueryPolicy
Return the prepared policy backing this descriptor.
Sourcepub fn requires_id(&self) -> bool
pub fn requires_id(&self) -> bool
Return whether this descriptor needs an id binding before execution.
Sourcepub fn static_key_value(&self) -> Option<&str>
pub fn static_key_value(&self) -> Option<&str>
Return the static logical key, if this descriptor has one.
Sourcepub fn entity_key_prefix(&self) -> Option<&str>
pub fn entity_key_prefix(&self) -> Option<&str>
Return the precomputed entity key prefix, if this is an entity policy.
Return the precomputed tags.
Sourcepub fn refresh_policy_value(&self) -> Option<RefreshOptions>
pub fn refresh_policy_value(&self) -> Option<RefreshOptions>
Return the configured refresh/stale policy.
Sourcepub fn refresh_policy(self, refresh: RefreshOptions) -> Self
pub fn refresh_policy(self, refresh: RefreshOptions) -> Self
Replace refresh/stale behavior for this prepared descriptor.
Sourcepub fn to_query(&self) -> DbQuery<T, C>
pub fn to_query(&self) -> DbQuery<T, C>
Create a runtime query from a static prepared policy.
Entity-id policies should usually use PreparedDbQuery::for_id so the
dynamic id becomes part of the key and entity invalidation tag.
Sourcepub fn for_id(&self, id: impl ToString) -> DbQuery<T, C>
pub fn for_id(&self, id: impl ToString) -> DbQuery<T, C>
Bind an id and create a runtime query.
Sourcepub async fn load<E, F, Fut>(&self, loader: F) -> Result<T>
pub async fn load<E, F, Fut>(&self, loader: F) -> Result<T>
Fetch a cached value from a static prepared policy or run the loader.
Sourcepub async fn load_id<E, F, Fut>(
&self,
id: impl ToString,
loader: F,
) -> Result<T>
pub async fn load_id<E, F, Fut>( &self, id: impl ToString, loader: F, ) -> Result<T>
Bind an id, fetch a cached value, or run the loader.
Sourcepub async fn fetch_value_with<U, E, F, Fut>(&self, loader: F) -> Result<U>
pub async fn fetch_value_with<U, E, F, Fut>(&self, loader: F) -> Result<U>
Fetch a static prepared value with an output type chosen by an adapter.
Sourcepub async fn fetch_value_with_id<U, E, F, Fut>(
&self,
id: impl ToString,
loader: F,
) -> Result<U>
pub async fn fetch_value_with_id<U, E, F, Fut>( &self, id: impl ToString, loader: F, ) -> Result<U>
Bind an id and fetch a value with an output type chosen by an adapter.