move lru cachers to pbs-tools

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-07-20 10:57:22 +02:00
parent 38629c3961
commit 6c221244df
6 changed files with 11 additions and 9 deletions

View File

@ -7,8 +7,8 @@ use std::collections::HashMap;
use std::future::Future;
use std::sync::{Arc, Mutex};
use super::lru_cache::LruCache;
use super::BroadcastFuture;
use crate::broadcast_future::BroadcastFuture;
use crate::lru_cache::LruCache;
/// Interface for asynchronously getting values on cache misses.
pub trait AsyncCacher<K, V: Clone>: Sync + Send {

View File

@ -19,5 +19,8 @@ pub mod tokio;
pub mod xattr;
pub mod zip;
pub mod async_lru_cache;
pub mod lru_cache;
mod command;
pub use command::{command_output, command_output_as_string, run_command};

View File

@ -13,9 +13,9 @@ use tokio::io::{AsyncRead, AsyncSeek, ReadBuf};
use proxmox::io_format_err;
use proxmox::sys::error::io_err_other;
use pbs_datastore::index::IndexFile;
use pbs_datastore::read_chunk::AsyncReadChunk;
use super::IndexFile;
use crate::tools::async_lru_cache::{AsyncCacher, AsyncLruCache};
use pbs_tools::async_lru_cache::{AsyncCacher, AsyncLruCache};
struct AsyncChunkCacher<T> {
reader: Arc<T>,

View File

@ -11,6 +11,7 @@ use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
use pbs_datastore::dynamic_index::DynamicIndexReader;
use pbs_datastore::read_chunk::ReadChunk;
use pbs_datastore::index::IndexFile;
use pbs_tools::lru_cache::LruCache;
struct CachedChunk {
range: Range<u64>,
@ -39,7 +40,7 @@ pub struct BufferedDynamicReader<S> {
buffered_chunk_idx: usize,
buffered_chunk_start: u64,
read_offset: u64,
lru_cache: crate::tools::lru_cache::LruCache<usize, CachedChunk>,
lru_cache: LruCache<usize, CachedChunk>,
}
struct ChunkCacher<'a, S> {
@ -47,7 +48,7 @@ struct ChunkCacher<'a, S> {
index: &'a DynamicIndexReader,
}
impl<'a, S: ReadChunk> crate::tools::lru_cache::Cacher<usize, CachedChunk> for ChunkCacher<'a, S> {
impl<'a, S: ReadChunk> pbs_tools::lru_cache::Cacher<usize, CachedChunk> for ChunkCacher<'a, S> {
fn fetch(&mut self, index: usize) -> Result<Option<CachedChunk>, Error> {
let info = match self.index.chunk_info(index) {
Some(info) => info,
@ -70,7 +71,7 @@ impl<S: ReadChunk> BufferedDynamicReader<S> {
buffered_chunk_idx: 0,
buffered_chunk_start: 0,
read_offset: 0,
lru_cache: crate::tools::lru_cache::LruCache::new(32),
lru_cache: LruCache::new(32),
}
}

View File

@ -38,8 +38,6 @@ pub use memcom::Memcom;
pub mod logrotate;
pub mod loopdev;
pub mod lru_cache;
pub mod async_lru_cache;
pub mod serde_filter;
pub mod statistics;
pub mod subscription;