feat: B50 fetchall impl

This commit is contained in:
mokurin000
2025-08-02 19:56:30 +08:00
parent 84edce688d
commit 957166d8f4
3 changed files with 40 additions and 7 deletions

View File

@@ -20,6 +20,19 @@ use bincode::{BorrowDecode, Encode, borrow_decode_from_slice};
use crate::{EARLY_QUIT, cache};
pub fn read_cache_keys(
definition: TableDefinition<'_, u32, Vec<u8>>,
) -> Result<Vec<u32>, Box<dyn snafu::Error>> {
let txn = cache::read_txn()?;
let table = cache::open_table_ro(&txn, definition)?;
Ok(table
.iter()?
.flatten()
.map(|(value, _)| value.value())
.collect::<Vec<u32>>())
}
pub fn read_cache<D>(
definition: TableDefinition<'_, u32, Vec<u8>>,
) -> Result<Vec<D>, Box<dyn snafu::Error>>
@@ -123,7 +136,7 @@ where
}
Err(sdgb_api::ApiError::JSON { .. }) => {}
Err(e) => {
error!("preview failed: {e}");
error!("fetch failed: {e}");
}
}