pub struct SecureCache<'a> { /* private fields */ }Expand description
Encrypted cache handle returned by CacheKit::secure().
All values are serialized, then encrypted with AES-256-GCM before storage. L1 stores ciphertext to maintain zero-knowledge guarantees.
Implementations§
Source§impl SecureCache<'_>
impl SecureCache<'_>
Sourcepub async fn set<T: Serialize>(
&self,
key: &str,
value: &T,
) -> Result<(), CachekitError>
pub async fn set<T: Serialize>( &self, key: &str, value: &T, ) -> Result<(), CachekitError>
Encrypt and store value under key using the client’s default TTL.
Sourcepub async fn set_with_ttl<T: Serialize>(
&self,
key: &str,
value: &T,
ttl: Duration,
) -> Result<(), CachekitError>
pub async fn set_with_ttl<T: Serialize>( &self, key: &str, value: &T, ttl: Duration, ) -> Result<(), CachekitError>
Encrypt and store value under key with an explicit ttl.
Sourcepub async fn get<T: DeserializeOwned>(
&self,
key: &str,
) -> Result<Option<T>, CachekitError>
pub async fn get<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<T>, CachekitError>
Retrieve, decrypt, and deserialize a value stored under key.
Checks L1 (which holds ciphertext) before the backend.
Sourcepub async fn interop_get<T: DeserializeOwned>(
&self,
key: &str,
) -> Result<Option<T>, CachekitError>
pub async fn interop_get<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<T>, CachekitError>
Retrieve, decrypt, and deserialize an interop-mode value stored under key.
Identical to Self::get except the decrypted plaintext is decoded
with crate::interop::deserialize — exactly one MessagePack document,
trailing bytes rejected (interop/v1 spec MUST). In interop mode the
AES-GCM plaintext is the plain MessagePack value bytes, so the AAD
(v0x03, format="msgpack", compressed="False") verifies cross-SDK
unchanged.
§Errors
Returns CachekitError::Config on a namespace-prefixed client — see
CacheKit::interop_get.
Sourcepub async fn delete(&self, key: &str) -> Result<bool, CachekitError>
pub async fn delete(&self, key: &str) -> Result<bool, CachekitError>
Delete an encrypted key. Behaves identically to CacheKit::delete.
Sourcepub async fn exists(&self, key: &str) -> Result<bool, CachekitError>
pub async fn exists(&self, key: &str) -> Result<bool, CachekitError>
Check if an encrypted key exists. Behaves identically to CacheKit::exists.