#[non_exhaustive]pub struct TenantCache { /* private fields */ }Expand description
Cache facade permanently bound to one authenticated tenant context.
Every operation derives the backend key from the immutable tenant identity.
The wrapper intentionally has no global flush; callers may only forget
explicit keys inside their tenant namespace.
Implementations§
Source§impl TenantCache
impl TenantCache
Sourcepub fn from_context(cache: Cache, context: &TenantContext) -> TenantCache
pub fn from_context(cache: Cache, context: &TenantContext) -> TenantCache
Binds a cache to a tenant already validated by authentication.
Sourcepub fn tenant_id(&self) -> &str
pub fn tenant_id(&self) -> &str
Returns the authenticated tenant identifier bound to this instance.
Sourcepub fn namespaced_key(&self, logical_key: &str) -> Result<String, CacheError>
pub fn namespaced_key(&self, logical_key: &str) -> Result<String, CacheError>
Returns the canonical backend key within this instance’s tenant namespace.
Sourcepub async fn get(
&self,
logical_key: &str,
) -> Result<Option<Arc<String>>, CacheError>
pub async fn get( &self, logical_key: &str, ) -> Result<Option<Arc<String>>, CacheError>
Retrieves a value only from this instance’s tenant namespace.
Sourcepub async fn put(
&self,
logical_key: &str,
value: &str,
ttl_secs: Option<u64>,
) -> Result<(), CacheError>
pub async fn put( &self, logical_key: &str, value: &str, ttl_secs: Option<u64>, ) -> Result<(), CacheError>
Stores a value only inside this instance’s tenant namespace.
Sourcepub async fn has(&self, logical_key: &str) -> Result<bool, CacheError>
pub async fn has(&self, logical_key: &str) -> Result<bool, CacheError>
Checks for a value only inside this instance’s tenant namespace.
Trait Implementations§
Source§impl Clone for TenantCache
impl Clone for TenantCache
Source§fn clone(&self) -> TenantCache
fn clone(&self) -> TenantCache
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TenantCache
impl !UnwindSafe for TenantCache
impl Freeze for TenantCache
impl Send for TenantCache
impl Sync for TenantCache
impl Unpin for TenantCache
impl UnsafeUnpin for TenantCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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