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

Method validate_cache

crate/server_database/src/core/object_cache.rs:126–133  ·  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

124 /// Call this whenever a fresh DB copy of the object is available (e.g.
125 /// after a forced re-fetch) to detect out-of-band mutations.
126 pub async fn validate_cache(&self, uid: &str, current_object: &Object) -> DbResult<()> {
127 if let Some(entry) = self.inner.get(uid).await {
128 if entry.fingerprint != self.fingerprinter.fingerprint(current_object)? {
129 self.inner.invalidate(uid).await;
130 }
131 }
132 Ok(())
133 }
134
135 /// Insert or update a cached object.
136 pub async fn insert(&self, uid: String, owm: ObjectWithMetadata) -> DbResult<()> {

Calls 3

invalidateMethod · 0.80
getMethod · 0.45
fingerprintMethod · 0.45