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