update deps and switch to upsert (thank god)
This commit is contained in:
parent
0663b7d4d5
commit
bf6a7ade5a
2 changed files with 598 additions and 318 deletions
885
Cargo.lock
generated
885
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -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)]
|
||||
|
|
Loading…
Reference in a new issue