pub struct Cache { /* private fields */ }Expand description
Values of up to 1 MiB under keys of 1 to 512 bytes, per tenant and domain, held in the
kernel’s memory (granted cache); see crate::Kernable::cache. A restart of the kernel
empties the cache; values are not part of the signed event log, and erasing a vault subject
does not delete them. For rate limits, short-lived tokens and computed values. A refused
or invalid request is Error::Status; a middleware that refuses it (checking SetCache,
GetCache or DeleteCache of the domain) makes it PERMISSION_DENIED with
"<code>: <message>". Example:
kernable.cache().set("shop", "rate:c1", "3", Some(Duration::from_secs(60))).await?, then
kernable.cache().get("shop", "rate:c1").await? returns Some(b"3".to_vec()).
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn tenant(self, tenant: impl Into<String>) -> Cache
pub fn tenant(self, tenant: impl Into<String>) -> Cache
The tenant to keep values under. Default: the connection’s (crate::Options::tenant).
Sourcepub fn context(self, context: RequestContext) -> Cache
pub fn context(self, context: RequestContext) -> Cache
Replaces the client’s default context for the requests of this handle (signed with
each; middlewares decide on it); inside a listener, pass ctx.follow(). Example:
kernable.cache().context(alice).get("shop", "k").await?.
Sourcepub async fn set(
&self,
domain: &str,
key: &str,
value: impl Into<Vec<u8>>,
ttl: Option<Duration>,
) -> Result<(), Error>
pub async fn set( &self, domain: &str, key: &str, value: impl Into<Vec<u8>>, ttl: Option<Duration>, ) -> Result<(), Error>
Stores value as key of domain (granted cache), replacing any value there. With a
ttl, the value expires after it; without, it stays until deleted or the kernel
restarts. A &str or String is stored as UTF-8.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Cache
impl !RefUnwindSafe for Cache
impl !UnwindSafe for Cache
impl Forget for Cache
impl Move for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cachewhere
*const ArcInner<Channels> is !null: UnsafeUnpin,
PhantomData<ArcInner<Channels>>: UnsafeUnpin,
*const ArcInner<Partitions> is !null: UnsafeUnpin,
PhantomData<ArcInner<Partitions>>: UnsafeUnpin,
*const ArcInner<SigningKey> is !null: UnsafeUnpin,
PhantomData<ArcInner<SigningKey>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const u8: UnsafeUnpin,
Align8<*mut ()>: UnsafeUnpin,
&'static Vtable: UnsafeUnpin,
PhantomData<Ascii>: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const LeafNode<String, String> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, String)>>: UnsafeUnpin,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request