update deps and switch to upsert (thank god)

This commit is contained in:
slonkazoid 2024-12-28 18:30:10 +03:00
parent 0663b7d4d5
commit bf6a7ade5a
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM
2 changed files with 598 additions and 318 deletions

885
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -79,28 +79,17 @@ impl Cache {
mtime: u64, mtime: u64,
rendered: Arc<str>, rendered: Arc<str>,
extra: u64, extra: u64,
) -> Result<(), (CacheKey, (PostMetadata, Arc<str>))> { ) -> Option<CacheValue> {
let key = CacheKey { name, extra }; self.0
.upsert_async(
let value = CacheValue { CacheKey { name, extra },
meta: metadata, CacheValue {
body: rendered, meta: metadata,
mtime, body: rendered,
}; mtime,
},
if self )
.0
.update_async(&key, |_, _| value.clone())
.await .await
.is_none()
{
self.0
.insert_async(key, value)
.await
.map_err(|x| (x.0, (x.1.meta, x.1.body)))
} else {
Ok(())
}
} }
#[allow(unused)] #[allow(unused)]