pub(crate) struct DiskCache {
path: PathBuf,
max_size: usize,
inner: Mutex<DiskCacheInner>,
}Expand description
A struct representing the disk cache.
Fields§
§path: PathBuf§max_size: usize§inner: Mutex<DiskCacheInner>Implementations§
Source§impl DiskCache
impl DiskCache
Sourcepub(crate) fn new(
cache_assignment: HttpCacheAssignment,
) -> (Option<Arc<DiskCache>>, MemoryCacheLifecycle)
pub(crate) fn new( cache_assignment: HttpCacheAssignment, ) -> (Option<Arc<DiskCache>>, MemoryCacheLifecycle)
Creates a new DiskCache if the preference if set.
Creates the sqlite table if it does not exist and starts the db connection.
TODO: Implement WAL and other sqlite pragma.
Sourcepub(crate) async fn get(
&self,
key: CacheKey,
) -> Option<Arc<TokioRwLock<Vec<CachedResource>>>>
pub(crate) async fn get( &self, key: CacheKey, ) -> Option<Arc<TokioRwLock<Vec<CachedResource>>>>
Restores a cache entry from the disk if it exists. Deletes the entry from the disk cache
Sourcepub(crate) async fn store(
&self,
key: CacheKey,
entry: Arc<RwLock<Vec<CachedResource>>>,
)
pub(crate) async fn store( &self, key: CacheKey, entry: Arc<RwLock<Vec<CachedResource>>>, )
Stores a CacheEntry` to disk.
Sourceasync fn delete_until_cache_size(&self)
async fn delete_until_cache_size(&self)
Deletes data from the cache until the size is <= max_size
Sourcefn get_disk_cache_total_size(&self, conn: &Connection) -> Option<usize>
fn get_disk_cache_total_size(&self, conn: &Connection) -> Option<usize>
Queries the current disk cache size from the sql database.
Trait Implementations§
Source§impl MallocSizeOf for DiskCache
impl MallocSizeOf for DiskCache
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
Auto Trait Implementations§
impl !Freeze for DiskCache
impl !RefUnwindSafe for DiskCache
impl Send for DiskCache
impl Sync for DiskCache
impl Unpin for DiskCache
impl UnsafeUnpin for DiskCache
impl !UnwindSafe for DiskCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert