pub struct CacheManager { /* private fields */ }Expand description
Manager for cached DuckDB databases
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub fn with_dir(cache_dir: PathBuf) -> Result<Self>
pub fn with_dir(cache_dir: PathBuf) -> Result<Self>
Create a cache manager with a custom cache directory
Sourcepub fn default_cache_dir() -> Result<PathBuf>
pub fn default_cache_dir() -> Result<PathBuf>
Get the default cache directory (SQL_SPLITTER_CACHE_DIR overrides)
Sourcepub fn compute_cache_key(
dump_path: &Path,
tables: Option<&[String]>,
dialect: Option<SqlDialect>,
) -> Result<String>
pub fn compute_cache_key( dump_path: &Path, tables: Option<&[String]>, dialect: Option<SqlDialect>, ) -> Result<String>
Compute the cache key for a dump file and import configuration
Sourcepub fn cache_path(&self, cache_key: &str) -> PathBuf
pub fn cache_path(&self, cache_key: &str) -> PathBuf
Get the path where a cached database would be stored
Sourcepub fn partial_path(&self, cache_key: &str) -> PathBuf
pub fn partial_path(&self, cache_key: &str) -> PathBuf
Get the staging path where a cache is built before being committed
Sourcepub fn has_valid_cache(
&self,
dump_path: &Path,
tables: Option<&[String]>,
dialect: Option<SqlDialect>,
) -> Result<bool>
pub fn has_valid_cache( &self, dump_path: &Path, tables: Option<&[String]>, dialect: Option<SqlDialect>, ) -> Result<bool>
Check if a valid cache exists for a dump file and import configuration.
Existence is sufficient: the key encodes the dump’s size and mtime, and files only appear at the final path via atomic rename of a complete copy.
Sourcepub fn get_cache(
&self,
dump_path: &Path,
tables: Option<&[String]>,
dialect: Option<SqlDialect>,
) -> Result<Option<PathBuf>>
pub fn get_cache( &self, dump_path: &Path, tables: Option<&[String]>, dialect: Option<SqlDialect>, ) -> Result<Option<PathBuf>>
Get the cache path for a dump file, if a valid cache exists
Sourcepub fn discard_partial(&self, cache_key: &str) -> Result<()>
pub fn discard_partial(&self, cache_key: &str) -> Result<()>
Remove a staged partial cache file (leftover from an interrupted run)
Sourcepub fn commit_cache(
&self,
dump_path: &Path,
cache_key: &str,
tables: Vec<String>,
row_count: u64,
) -> Result<PathBuf>
pub fn commit_cache( &self, dump_path: &Path, cache_key: &str, tables: Vec<String>, row_count: u64, ) -> Result<PathBuf>
Commit a fully-written partial cache file: atomically move it into place and update the index. The previous cache and index are untouched if this (or anything before it) fails.
Sourcepub fn load_index(&self) -> Result<CacheIndex>
pub fn load_index(&self) -> Result<CacheIndex>
Load the cache index. A corrupt index is treated as empty (with a warning) so one bad write can’t permanently brick cache operations.
Sourcepub fn list_entries(&self) -> Result<Vec<CacheEntry>>
pub fn list_entries(&self) -> Result<Vec<CacheEntry>>
List all cache entries
Sourcepub fn remove_cache(&self, cache_key: &str) -> Result<()>
pub fn remove_cache(&self, cache_key: &str) -> Result<()>
Remove a specific cache entry
Sourcepub fn clear_all(&self) -> Result<usize>
pub fn clear_all(&self) -> Result<usize>
Clear all cached databases.
Sweeps the whole cache directory (data files, WAL files, staged partials) rather than trusting the index, so it also recovers from a lost/corrupt index and collects files written by older versions. Returns the number of cached databases removed.
Sourcepub fn total_size(&self) -> Result<u64>
pub fn total_size(&self) -> Result<u64>
Get total cache size in bytes
Auto Trait Implementations§
impl Freeze for CacheManager
impl RefUnwindSafe for CacheManager
impl Send for CacheManager
impl Sync for CacheManager
impl Unpin for CacheManager
impl UnsafeUnpin for CacheManager
impl UnwindSafe for CacheManager
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more