pub struct Cache { /* private fields */ }Implementations§
Source§impl Cache
impl Cache
pub fn new(ttl: Duration, body_cap: usize) -> Self
Sourcepub fn has_listing(&self, dir: &str) -> bool
pub fn has_listing(&self, dir: &str) -> bool
Is there a listing for this directory that is still inside its TTL?
Distinct from attrs_of returning None, which cannot tell “no listing” from
“listed, and the name is not in it”. The origin layer needs that difference:
the second is a 404 it can answer locally, the first is a fetch.
Sourcepub fn attrs_of(&self, dir: &str, name: &str) -> Option<Attrs>
pub fn attrs_of(&self, dir: &str, name: &str) -> Option<Attrs>
Attrs for one entry of a fresh listing. Attrs is Copy, so this does not
clone the map.
Sourcepub fn listing_entries(&self, dir: &str) -> Option<Vec<Entry>>
pub fn listing_entries(&self, dir: &str) -> Option<Vec<Entry>>
A fresh listing as entries, for rendering a directory index.
Unlike attrs_of this clones, because an autoindex needs every name anyway
and holding the lock across the render would block every other request.
pub fn put_listing(&self, dir: &str, entries: &[Entry])
Sourcepub fn forget_listing(&self, dir: &str)
pub fn forget_listing(&self, dir: &str)
Forget a listing so the next request refetches it.
Called when a fetch contradicts the listing: a file the listing promised, and the remote refused. Keeping a listing that has been proven wrong would serve the same wrong answer for a whole TTL.