add back the consume_budget on cache hits

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-12-08 05:45:15 +00:00
parent 6aa35260e6
commit ff56ee7413

View file

@ -2,8 +2,9 @@ use std::{convert::AsRef, fmt::Debug, io::Write, sync::Arc};
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use conduit::{err, implement, utils::result::MapExpect, Err, Result}; use conduit::{err, implement, utils::result::MapExpect, Err, Result};
use futures::{future, Future, FutureExt}; use futures::{Future, FutureExt};
use serde::Serialize; use serde::Serialize;
use tokio::task;
use crate::{ use crate::{
keyval::KeyBuf, keyval::KeyBuf,
@ -63,7 +64,9 @@ where
let cached = self.get_cached(key); let cached = self.get_cached(key);
if matches!(cached, Err(_) | Ok(Some(_))) { if matches!(cached, Err(_) | Ok(Some(_))) {
return future::ready(cached.map_expect("data found in cache")).boxed(); return task::consume_budget()
.map(move |()| cached.map_expect("data found in cache"))
.boxed();
} }
debug_assert!(matches!(cached, Ok(None)), "expected status Incomplete"); debug_assert!(matches!(cached, Ok(None)), "expected status Incomplete");