MCPcopy Create free account
hub / github.com/Cosmian/kms / validate_cache

Method validate_cache

crate/server_database/src/core/object_cache.rs:93–100  ·  view source on GitHub ↗

Validate the cache entry for `uid` against the current object from the DB. If the fingerprint of the cached entry differs from the fingerprint of `current_object`, the entry is invalidated so the next `get` will trigger a fresh DB fetch. A match is a no-op (the entry stays warm). Call this whenever a fresh DB copy of the object is available (e.g. after a forced re-fetch) to detect out-of-band m

(&self, uid: &str, current_object: &Object)

Source from the content-addressed store, hash-verified

91 /// Call this whenever a fresh DB copy of the object is available (e.g.
92 /// after a forced re-fetch) to detect out-of-band mutations.
93 pub async fn validate_cache(&self, uid: &str, current_object: &Object) -> DbResult<()> {
94 if let Some(entry) = self.inner.get(uid).await {
95 if entry.fingerprint != self.fingerprinter.fingerprint(current_object)? {
96 self.inner.invalidate(uid).await;
97 }
98 }
99 Ok(())
100 }
101
102 /// Insert or update a cached object.
103 pub async fn insert(&self, uid: String, owm: ObjectWithMetadata) -> DbResult<()> {

Calls 3

invalidateMethod · 0.80
getMethod · 0.45
fingerprintMethod · 0.45