FoundationDB fixes

This commit is contained in:
mdecimus 2024-05-10 08:04:34 +02:00
parent 1e908f7737
commit cf6765b70d
3 changed files with 4 additions and 8 deletions

View file

@ -202,10 +202,6 @@ impl<T, E: Display> UnwrapResult<T> for Result<T, E> {
}
}
trait TableName {
fn table_name(&self) -> &'static str;
}
pub fn read_file(path: &str) -> Vec<u8> {
if path == "-" {
let mut stdin = std::io::stdin().lock();

View file

@ -50,7 +50,7 @@ impl ReadVersion {
pub fn new(version: i64) -> Self {
Self {
version,
expires: Instant::now() + Duration::from_secs(60 * 2),
expires: Instant::now() + Duration::from_secs(1),
}
}

View file

@ -142,19 +142,19 @@ impl FdbStore {
}
pub(crate) async fn read_trx(&self) -> crate::Result<Transaction> {
let trx = self.db.create_trx()?;
let (is_expired, mut read_version) = {
let version = self.version.lock();
(version.is_expired(), version.version)
};
let trx = self.db.create_trx()?;
if is_expired {
read_version = trx.get_read_version().await?;
*self.version.lock() = ReadVersion::new(read_version);
} else {
trx.set_read_version(read_version);
}
trx.set_read_version(read_version);
Ok(trx)
}
}