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 the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for ReadOnlyCache
impl Send for ReadOnlyCache
impl Sync for ReadOnlyCache
impl Unpin for ReadOnlyCache
impl UnwindSafe for ReadOnlyCache
Blanket Implementations
Mutably borrows from an owned value. Read more