Skip to main content

HttpCacheStore

Struct HttpCacheStore 

Source
pub struct HttpCacheStore {
    entries: BTreeMap<String, (HttpCacheEntry, Vec<u8>)>,
    pub max_entries: usize,
    pub max_total_bytes: usize,
    current_total_bytes: usize,
}
Expand description

メモリ上の HTTP キャッシュストア

Fields§

§entries: BTreeMap<String, (HttpCacheEntry, Vec<u8>)>§max_entries: usize§max_total_bytes: usize§current_total_bytes: usize

Implementations§

Source§

impl HttpCacheStore

Source

pub const DEFAULT_MAX_ENTRIES: usize = 128

Source

pub const DEFAULT_MAX_TOTAL_BYTES: usize

Source

pub const fn new() -> Self

Source

pub fn lookup_with_headers<K: AsRef<str>, V: AsRef<str>>( &self, url: &str, req_headers: &[(K, V)], now_sec: u64, ) -> CacheLookup

URL および要求ヘッダをキーにキャッシュを照会する(RFC 7234 Vary 照合対応)。

Source

pub fn lookup(&self, url: &str, now_sec: u64) -> CacheLookup

URL をキーにキャッシュを照会する(空の要求ヘッダで照会)。

Source

pub fn put_with_request_headers<K: AsRef<str>, V: AsRef<str>, RK: AsRef<str>, RV: AsRef<str>>( &mut self, url: &str, status_code: u16, resp_headers: &[(K, V)], req_headers: &[(RK, RV)], body: &[u8], now_sec: u64, ) -> bool

レスポンスおよび要求ヘッダをキャッシュに保存する(Vary ヘッダ対応)。

Source

pub fn put<K: AsRef<str>, V: AsRef<str>>( &mut self, url: &str, status_code: u16, headers: &[(K, V)], body: &[u8], now_sec: u64, ) -> bool

レスポンスをキャッシュに保存する(no-store の場合は保存しない)。

Source

pub fn handle_304<K: AsRef<str>, V: AsRef<str>>( &mut self, url: &str, headers: &[(K, V)], now_sec: u64, ) -> Option<Vec<u8>>

304 Not Modified 受信時にメタデータを更新し、保存済みボディを返す。

Source

pub fn remove(&mut self, url: &str) -> bool

指定 URL のキャッシュを削除する。

Source

pub fn len(&self) -> usize

キャッシュエントリ数を取得する。

Source

pub fn is_empty(&self) -> bool

キャッシュが空か判定する。

Source

pub fn total_bytes(&self) -> usize

キャッシュされた全ボディの合計バイト数を取得する。

Source

pub fn clear(&mut self)

全エントリをクリアする。

Trait Implementations§

Source§

impl Default for HttpCacheStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.