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: usizeImplementations§
Source§impl HttpCacheStore
impl HttpCacheStore
pub const DEFAULT_MAX_ENTRIES: usize = 128
pub const DEFAULT_MAX_TOTAL_BYTES: usize
pub const fn new() -> Self
Sourcepub fn lookup_with_headers<K: AsRef<str>, V: AsRef<str>>(
&self,
url: &str,
req_headers: &[(K, V)],
now_sec: u64,
) -> CacheLookup
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 照合対応)。
Sourcepub fn lookup(&self, url: &str, now_sec: u64) -> CacheLookup
pub fn lookup(&self, url: &str, now_sec: u64) -> CacheLookup
URL をキーにキャッシュを照会する(空の要求ヘッダで照会)。
Sourcepub 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
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 ヘッダ対応)。
Sourcepub fn put<K: AsRef<str>, V: AsRef<str>>(
&mut self,
url: &str,
status_code: u16,
headers: &[(K, V)],
body: &[u8],
now_sec: u64,
) -> bool
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 の場合は保存しない)。
Sourcepub fn handle_304<K: AsRef<str>, V: AsRef<str>>(
&mut self,
url: &str,
headers: &[(K, V)],
now_sec: u64,
) -> Option<Vec<u8>>
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 受信時にメタデータを更新し、保存済みボディを返す。
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
キャッシュされた全ボディの合計バイト数を取得する。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HttpCacheStore
impl RefUnwindSafe for HttpCacheStore
impl Send for HttpCacheStore
impl Sync for HttpCacheStore
impl Unpin for HttpCacheStore
impl UnsafeUnpin for HttpCacheStore
impl UnwindSafe for HttpCacheStore
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