Skip to content

Commit 8939fe7

Browse files
RUST-2006 Add option to configure DEK cache lifetime (#38)
1 parent bd5b9f4 commit 8939fe7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mongocrypt/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,17 @@ impl CryptBuilder {
259259
Ok(self)
260260
}
261261

262+
/// Set the expiration time for the data encryption key cache. Defaults to 60 seconds if not set.
263+
pub fn key_cache_expiration(self, expiration_ms: u64) -> Result<Self> {
264+
unsafe {
265+
let ok = sys::mongocrypt_setopt_key_expiration(*self.inner.borrow(), expiration_ms);
266+
if !ok {
267+
return Err(self.status().as_error())
268+
}
269+
}
270+
Ok(self)
271+
}
272+
262273
pub fn build(mut self) -> Result<Crypt> {
263274
let _guard = CRYPT_LOCK.lock().unwrap();
264275

0 commit comments

Comments
 (0)