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

Returns a fresh empty builder.

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.

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.

Returns a fresh Cache for the builder’s write cache and additional search list of read-only cache directories.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.