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)
| 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<()> { |