Struct kismet_cache::ReadOnlyCache[][src]

pub struct ReadOnlyCache { /* fields omitted */ }
Expand description

A ReadOnlyCache wraps an arbitrary number of crate::plain::Cache and crate::sharded::Cache, and attempts to satisfy ReadOnlyCache::get and ReadOnlyCache::touch requests by hitting each constituent cache in order. This interface hides the difference between plain and sharded cache directories, and should be the first resort for read-only uses.

The default cache wraps an empty set of constituent caches and performs no consistency check.

ReadOnlyCache objects are stateless and cheap to clone; don’t put an Arc on them. Avoid creating multiple ReadOnlyCaches for the same stack of directories: there is no internal state to maintain, so multiple instances simply waste memory without any benefit.

Implementations

Attempts to open a read-only file for key. The ReadOnlyCache will query each constituent cache in order of registration, and return a read-only file for the first hit.

Fails with ErrorKind::InvalidInput if key.name is invalid (empty, or starts with a dot or a forward or back slash).

Returns None if no file for key can be found in any of the constituent caches, and bubbles up the first I/O error encountered, if any.

In the worst case, each call to get attempts to open two files for each cache directory in the ReadOnlyCache stack.

Marks a cache entry for key as accessed (read). The ReadOnlyCache will touch the same file that would be returned by get.

Fails with ErrorKind::InvalidInput if key.name is invalid (empty, or starts with a dot or a forward or back slash).

Returns whether a file for key could be found, and bubbles up the first I/O error encountered, if any.

In the worst case, each call to touch attempts to update the access time on two files for each cache directory in the ReadOnlyCache stack.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.