From b0cdf1cdc08637eed89816183966e5cb22c2cc4a Mon Sep 17 00:00:00 2001 From: Isabel Atkinson Date: Mon, 13 Jan 2025 09:53:57 -0700 Subject: [PATCH] RUST-2006 Add option to configure DEK cache lifetime --- mongocrypt/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mongocrypt/src/lib.rs b/mongocrypt/src/lib.rs index 49627dc..ccb6100 100644 --- a/mongocrypt/src/lib.rs +++ b/mongocrypt/src/lib.rs @@ -259,6 +259,17 @@ impl CryptBuilder { Ok(self) } + /// Set the expiration time for the data encryption key cache. Defaults to 60 seconds if not set. + pub fn key_cache_expiration(self, expiration_ms: u64) -> Result { + unsafe { + let ok = sys::mongocrypt_setopt_key_expiration(*self.inner.borrow(), expiration_ms); + if !ok { + return Err(self.status().as_error()) + } + } + Ok(self) + } + pub fn build(mut self) -> Result { let _guard = CRYPT_LOCK.lock().unwrap();