Struct kismet_cache::CacheBuilder [−][src]
pub struct CacheBuilder { /* fields omitted */ }Expand description
Construct a Cache with this builder. The resulting cache will
always first access its write-side cache (if defined), and, on
misses, will attempt to service Cache::get and
Cache::touch calls by iterating over the read-only caches.
Implementations
pub fn consistency_checker(
self,
checker: impl Fn(&mut File, &mut File) -> Result<()> + Sync + Send + RefUnwindSafe + UnwindSafe + Sized + 'static
) -> Self
pub fn consistency_checker(
self,
checker: impl Fn(&mut File, &mut File) -> Result<()> + Sync + Send + RefUnwindSafe + UnwindSafe + Sized + 'static
) -> Self
Sets the consistency checker function: when the function is
provided, the ReadOnlyCache will keep searching after the
first cache hit, and compare subsequent hits with the first
one by calling checker. The checker function should
return Ok(()) if the two files are compatible (identical),
and Err otherwise.
Kismet will propagate the error on mismatch.
Removes the consistency checker function, if any.
pub fn arc_consistency_checker(
self,
checker: Option<Arc<dyn Fn(&mut File, &mut File) -> Result<()> + Sync + Send + RefUnwindSafe + UnwindSafe>>
) -> Self
pub fn arc_consistency_checker(
self,
checker: Option<Arc<dyn Fn(&mut File, &mut File) -> Result<()> + Sync + Send + RefUnwindSafe + UnwindSafe>>
) -> Self
Sets the consistency checker function. None clears the
checker function. See CacheBuilder::consistency_checker.
Sets the read-write cache directory to path.
The read-write cache will be a plain cache directory if
num_shards <= 1, and a sharded directory otherwise.
Sets the read-write cache directory to a plain directory at
path, with a target file count of up to capacity.
Sets the read-write cache directory to a sharded directory at
path, with num_shards subdirectories and a target file
count of up to capacity for the entire cache.
Sets whether files published read-write cache will be
automatically flushed to disk with File::sync_all
before sending them to the cache directory.
Defaults to true, for safety. Even when auto_sync is
enabled, Kismet does not fsync cache directories; after a
kernel or hardware crash, caches may partially revert to an
older state, but should not contain incomplete files.
An application may want to disable auto_sync because it
already synchronises files, or because the cache directories
do not survive crashes: they might be erased after each boot,
e.g., via
tmpfiles.d,
or tagged with a boot id.
Adds a new read-only cache directory at path to the end of the
cache builder’s search list.
Adds a plain cache directory if num_shards <= 1, and a sharded
directory otherwise.
Adds a new plain (unsharded) read-only cache directory at
path to the end of the cache builder’s search list.
Adds a new sharded read-only cache directory at path to the
end of the cache builder’s search list.
Trait Implementations
Returns the “default value” for a type. Read more