[−][src]Struct sccache::lru_disk_cache::LruDiskCache
An LRU cache of files on disk.
Implementations
impl LruDiskCache
[src]
pub 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.
pub fn size(&self) -> u64
[src]
Return the current size of all the files in the cache.
pub fn len(&self) -> usize
[src]
Return the count of entries in the cache.
pub fn is_empty(&self) -> bool
[src]
pub fn capacity(&self) -> u64
[src]
Return the maximum size of the cache.
pub fn path(&self) -> &Path
[src]
Return the path in which the cache is stored.
pub fn can_store(&self, size: u64) -> bool
[src]
Returns true
if the disk cache can store a file of size
bytes.
pub fn insert_with<K: AsRef<OsStr>, F: FnOnce(File) -> Result<()>>(
&mut self,
key: K,
with: F
) -> Result<()>
[src]
&mut self,
key: K,
with: F
) -> Result<()>
Add a file by calling with
with the open File
corresponding to the cache at path key
.
pub fn insert_bytes<K: AsRef<OsStr>>(
&mut self,
key: K,
bytes: &[u8]
) -> Result<()>
[src]
&mut self,
key: K,
bytes: &[u8]
) -> Result<()>
Add a file with bytes
as its contents to the cache at path key
.
pub 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
.
pub fn contains_key<K: AsRef<OsStr>>(&self, key: K) -> bool
[src]
Return true
if a file with path key
is in the cache.
pub fn get_file<K: AsRef<OsStr>>(&mut self, key: K) -> Result<File>
[src]
Get an opened File
for key
, if one exists and can be opened. Updates the LRU state
of the file if present. Avoid using this method if at all possible, prefer .get
.
pub fn get<K: AsRef<OsStr>>(&mut self, key: K) -> Result<Box<dyn 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.
pub fn remove<K: AsRef<OsStr>>(&mut self, key: K) -> Result<()>
[src]
Remove the given key from the cache.
Auto Trait Implementations
impl<S> RefUnwindSafe for LruDiskCache<S> where
S: RefUnwindSafe,
[src]
S: RefUnwindSafe,
impl<S> Send for LruDiskCache<S> where
S: Send,
[src]
S: Send,
impl<S> Sync for LruDiskCache<S> where
S: Sync,
[src]
S: Sync,
impl<S> Unpin for LruDiskCache<S> where
S: Unpin,
[src]
S: Unpin,
impl<S> UnwindSafe for LruDiskCache<S> where
S: UnwindSafe,
[src]
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,