pub struct CacheKey {
pub method: Method,
pub path: ByteStr,
pub query: String,
pub vary_values: Vec<(String, String)>,
pub body_hash: Option<u64>,
}Expand description
Cache key for HTTP responses.
Fields§
§method: MethodHTTP method
path: ByteStrRequest path
query: StringCanonicalized query string: the decoded pairs sorted by name, each key
and value length-prefixed as {len}:{bytes}.
Not a re-rendered query string — the pairs arrive percent-decoded, so a
value may itself contain & or =. Joined naively, ?a=1%26b%3D2 (one
param whose value is 1&b=2) and ?a=1&b=2 (two params) both render
a=1&b=2 and would share a cache entry, letting one request be served
the other’s body. The length prefix fixes where each field ends
regardless of the bytes inside it, so distinct pair sets always differ
here.
vary_values: Vec<(String, String)>Vary header values that affect caching
body_hash: Option<u64>Hash of the request body, for methods where the body identifies the
resource being queried (QUERY, draft-ietf-httpbis-safe-method-w-body).
None for methods whose body does not participate in the cache key.
Implementations§
Source§impl CacheKey
impl CacheKey
Sourcepub fn from_request(request: &HttpRequest) -> Self
pub fn from_request(request: &HttpRequest) -> Self
Generate a cache key from a request.
Sourcepub fn from_request_with_vary(
request: &HttpRequest,
vary_headers: &[&str],
) -> Self
pub fn from_request_with_vary( request: &HttpRequest, vary_headers: &[&str], ) -> Self
Generate a cache key from a request with Vary headers.
Sourcepub fn to_string_key(&self) -> String
pub fn to_string_key(&self) -> String
Convert to a string representation suitable for use as a cache key.
Trait Implementations§
impl Eq for CacheKey
impl StructuralPartialEq for CacheKey
Auto Trait Implementations§
impl !Freeze for CacheKey
impl RefUnwindSafe for CacheKey
impl Send for CacheKey
impl Sync for CacheKey
impl Unpin for CacheKey
impl UnsafeUnpin for CacheKey
impl UnwindSafe for CacheKey
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<R, D> DepsPresent<D> for R
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Injectable for T
impl<T> Injectable for T
Source§fn type_id_of() -> TypeIdwhere
Self: Sized,
fn type_id_of() -> TypeIdwhere
Self: Sized,
Source§fn type_name_of() -> &'static strwhere
Self: Sized,
fn type_name_of() -> &'static strwhere
Self: Sized,
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>
impl<T> Provider for Twhere
T: Injectable,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more