batch queries to maximize throughput

query-side streams for first level of callsites

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-01-01 06:08:20 +00:00 committed by strawberry
parent 1792711d09
commit 2259e2c82f
13 changed files with 191 additions and 56 deletions

View file

@ -2,7 +2,7 @@ use std::{convert::AsRef, fmt::Debug, io::Write, sync::Arc};
use arrayvec::ArrayVec;
use conduwuit::{err, implement, utils::result::MapExpect, Err, Result};
use futures::{Future, FutureExt};
use futures::{future::ready, Future, FutureExt, TryFutureExt};
use serde::Serialize;
use tokio::task;
@ -79,11 +79,15 @@ where
debug_assert!(matches!(cached, Ok(None)), "expected status Incomplete");
let cmd = Get {
map: self.clone(),
key: key.as_ref().into(),
key: [key.as_ref().into()].into(),
res: None,
};
self.db.pool.execute_get(cmd).boxed()
self.db
.pool
.execute_get(cmd)
.and_then(|mut res| ready(res.remove(0)))
.boxed()
}
/// Fetch a value from the database into cache, returning a reference-handle.