Skip to content

Commit eddaf96

Browse files
authored
Merge pull request #3462 from matrix-org/valere/binding_ffi_crypto_expose_clear_caches
FFI Bindings: Expose CryptoStore clear caches
2 parents 16891ff + 0e456cd commit eddaf96

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

bindings/matrix-sdk-crypto-ffi/src/machine.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,17 @@ impl OlmMachine {
15341534
}
15351535
.into()
15361536
}
1537+
1538+
/// Clear any in-memory caches because they may be out of sync with the
1539+
/// underlying data store.
1540+
///
1541+
/// The crypto store layer is caching olm sessions for a given device.
1542+
/// When used in a multi-process context this cache will get outdated.
1543+
/// If the machine is used by another process, the cache must be
1544+
/// invalidating when the main process is resumed.
1545+
pub async fn clear_crypto_cache(&self) {
1546+
self.inner.clear_crypto_cache().await
1547+
}
15371548
}
15381549

15391550
impl OlmMachine {

crates/matrix-sdk-crypto/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ Deprecations:
5050

5151
Additions:
5252

53+
54+
- Expose new method `OlmMachine::clear_crypto_cache()`, with FFI bindings
55+
([#3462](https://github.com/matrix-org/matrix-rust-sdk/pull/3462))
56+
5357
- Expose new method `OlmMachine::upload_device_keys()`.
5458
([#3457](https://github.com/matrix-org/matrix-rust-sdk/pull/3457))
5559

crates/matrix-sdk-crypto/src/machine.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,13 @@ impl OlmMachine {
21502150
let account = cache.account().await?;
21512151
Ok(account.uploaded_key_count())
21522152
}
2153+
2154+
/// Clear any in-memory caches because they may be out of sync with the
2155+
/// underlying data store.
2156+
pub async fn clear_crypto_cache(&self) {
2157+
let crypto_store = self.store().crypto_store();
2158+
crypto_store.as_ref().clear_caches().await;
2159+
}
21532160
}
21542161

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

0 commit comments

Comments
 (0)