Skip to content

Commit

Permalink
Merge pull request #3462 from matrix-org/valere/binding_ffi_crypto_ex…
Browse files Browse the repository at this point in the history
…pose_clear_caches

FFI Bindings: Expose CryptoStore clear caches
  • Loading branch information
Hywan authored May 28, 2024
2 parents 16891ff + 0e456cd commit eddaf96
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bindings/matrix-sdk-crypto-ffi/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,17 @@ impl OlmMachine {
}
.into()
}

/// Clear any in-memory caches because they may be out of sync with the
/// underlying data store.
///
/// The crypto store layer is caching olm sessions for a given device.
/// When used in a multi-process context this cache will get outdated.
/// If the machine is used by another process, the cache must be
/// invalidating when the main process is resumed.
pub async fn clear_crypto_cache(&self) {
self.inner.clear_crypto_cache().await
}
}

impl OlmMachine {
Expand Down
4 changes: 4 additions & 0 deletions crates/matrix-sdk-crypto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ Deprecations:

Additions:


- Expose new method `OlmMachine::clear_crypto_cache()`, with FFI bindings
([#3462](https://github.com/matrix-org/matrix-rust-sdk/pull/3462))

- Expose new method `OlmMachine::upload_device_keys()`.
([#3457](https://github.com/matrix-org/matrix-rust-sdk/pull/3457))

Expand Down
7 changes: 7 additions & 0 deletions crates/matrix-sdk-crypto/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2150,6 +2150,13 @@ impl OlmMachine {
let account = cache.account().await?;
Ok(account.uploaded_key_count())
}

/// Clear any in-memory caches because they may be out of sync with the
/// underlying data store.
pub async fn clear_crypto_cache(&self) {
let crypto_store = self.store().crypto_store();
crypto_store.as_ref().clear_caches().await;
}
}

/// A set of requests to be executed when bootstrapping cross-signing using
Expand Down

0 comments on commit eddaf96

Please sign in to comment.