pub struct CacheBust(pub bool);Expand description
Per-request control for busting and refreshing cache behavior.
When set to CacheBust(true) in request extensions, the cache middleware
skips cache reads for that request, forces a fresh network fetch, and then
writes the new response back to cache (subject to CachePolicy).
This is useful when you want to refresh a stale entry and make future non-busted requests use the updated cached response.
§Example
use reqwest_drive::{CacheBust, CachePolicy, ThrottlePolicy, init_cache_with_throttle};
use reqwest_middleware::ClientBuilder;
use tempfile::tempdir;
let temp_dir = tempdir().unwrap();
let cache_path = temp_dir.path().join("cache_storage.bin");
let (cache, throttle) = init_cache_with_throttle(
&cache_path,
CachePolicy::default(),
ThrottlePolicy::default(),
);
let client = ClientBuilder::new(reqwest::Client::new())
.with_arc(cache)
.with_arc(throttle)
.build();
let mut request = client.get("https://example.com");
request.extensions().insert(CacheBust(true));
let _ = request.send().await;Tuple Fields§
§0: boolTrait Implementations§
impl Copy for CacheBust
Auto Trait Implementations§
impl Freeze for CacheBust
impl RefUnwindSafe for CacheBust
impl Send for CacheBust
impl Sync for CacheBust
impl Unpin for CacheBust
impl UnsafeUnpin for CacheBust
impl UnwindSafe for CacheBust
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