Struct lru_disk_cache::LruDiskCache
[−]
[src]
pub struct LruDiskCache<S: BuildHasher = RandomState> { /* fields omitted */ }
An LRU cache of files on disk.
Methods
impl LruDiskCache
[src]
fn new<T>(path: T, size: u64) -> Result<Self> where
PathBuf: From<T>,
[src]
PathBuf: From<T>,
Create an LruDiskCache
that stores files in path
, limited to size
bytes.
Existing files in path
will be stored with their last-modified time from the filesystem
used as the order for the recency of their use. Any files that are individually larger
than size
bytes will be removed.
The cache is not observant of changes to files under path
from external sources, it
expects to have sole maintence of the contents.
fn size(&self) -> u64
[src]
Return the current size of all the files in the cache.
fn capacity(&self) -> u64
[src]
Return the maximum size of the cache.
fn path(&self) -> &Path
[src]
Return the path in which the cache is stored.
fn can_store(&self, size: u64) -> bool
[src]
Returns true
if the disk cache can store a file of size
bytes.
fn insert_bytes<K: AsRef<OsStr>>(&mut self, key: K, bytes: &[u8]) -> Result<()>
[src]
Add a file with bytes
as its contents to the cache at path key
.
fn insert_file<K: AsRef<OsStr>, P: AsRef<OsStr>>(
&mut self,
key: K,
path: P
) -> Result<()>
[src]
&mut self,
key: K,
path: P
) -> Result<()>
Add an existing file at path
to the cache at path key
.
fn contains_key<K: AsRef<OsStr>>(&self, key: K) -> bool
[src]
Return true
if a file with path key
is in the cache.
fn get<K: AsRef<OsStr>>(&mut self, key: K) -> Result<Box<ReadSeek>>
[src]
Get an opened readable and seekable handle to the file at key
, if one exists and can
be opened. Updates the LRU state of the file if present.