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,
rendered: Arc<str>,
extra: u64,
) -> Result<(), (CacheKey, (PostMetadata, Arc<str>))> {
let key = CacheKey { name, extra };
let value = CacheValue {
meta: metadata,
body: rendered,
mtime,
};
if self
.0
.update_async(&key, |_, _| value.clone())
) -> Option<CacheValue> {
self.0
.upsert_async(
CacheKey { name, extra },
CacheValue {
meta: metadata,
body: rendered,
mtime,
},
)
.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)]