pub struct Cache<S: CacheStorage> { /* private fields */ }Expand description
Cache handler. Mount on a trillium_client::Client together with
a CacheStorage backend.
Cache is cheap to Clone: storage is held in an Arc, so clones
share the same backend.
Implementations§
Source§impl<S: CacheStorage> Cache<S>
impl<S: CacheStorage> Cache<S>
Sourcepub fn new(storage: S) -> Self
pub fn new(storage: S) -> Self
Construct a cache handler with default options
(CacheOptions::default) and a 16 MiB body-size cap.
Sourcepub fn with_options(self, options: CacheOptions) -> Self
pub fn with_options(self, options: CacheOptions) -> Self
Replace the cache options.
Mark this cache as a shared cache (proxy/CDN). Equivalent to
with_options with shared: true.
Sourcepub fn with_max_cacheable_size(self, max: u64) -> Self
pub fn with_max_cacheable_size(self, max: u64) -> Self
Set the cap on response body bytes the cache will store. Responses larger than this pass through but are not stored. If the cap is exceeded mid-stream, the cache write is aborted and the remainder of the body passes through unmodified.
Trait Implementations§
Source§impl<S: CacheStorage> ClientHandler for Cache<S>
impl<S: CacheStorage> ClientHandler for Cache<S>
Source§async fn run(&self, conn: &mut Conn) -> Result<()>
async fn run(&self, conn: &mut Conn) -> Result<()>
Forward-pass hook, called before the network round-trip in declared order. Read more
Source§impl<S: CacheStorage> Clone for Cache<S>
impl<S: CacheStorage> Clone for Cache<S>
Auto Trait Implementations§
impl<S> Freeze for Cache<S>
impl<S> RefUnwindSafe for Cache<S>where
S: RefUnwindSafe,
impl<S> Send for Cache<S>
impl<S> Sync for Cache<S>
impl<S> Unpin for Cache<S>
impl<S> UnsafeUnpin for Cache<S>
impl<S> UnwindSafe for Cache<S>where
S: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.