pub struct CacheConfig {
pub cache_dir: PathBuf,
pub redis_url: Option<String>,
pub video_ttl: Option<u64>,
pub playlist_ttl: Option<u64>,
pub download_ttl: Option<u64>,
pub persistent_backend: Option<PersistentBackendKind>,
}Expand description
Configuration for the tiered cache system.
Uses TypedBuilder for ergonomic construction with sensible defaults.
ยงExamples
use std::path::PathBuf;
use yt_dlp::cache::CacheConfig;
let config = CacheConfig::builder()
.cache_dir(PathBuf::from("cache"))
.build();Fieldsยง
ยงcache_dir: PathBufDirectory where cache data will be stored.
redis_url: Option<String>Connection URL for Redis backend (e.g. โredis://127.0.0.1/โ).
Only used when cache-redis feature is enabled.
video_ttl: Option<u64>Time-to-live for video cache entries in seconds. Default: 24 hours (86400 seconds).
playlist_ttl: Option<u64>Time-to-live for playlist cache entries in seconds. Default: 6 hours (21600 seconds).
download_ttl: Option<u64>Time-to-live for download/file cache entries in seconds. Default: 7 days (604800 seconds).
persistent_backend: Option<PersistentBackendKind>Which persistent backend to activate at runtime.
Leave as None when exactly one persistent feature is compiled in
(it is deduced automatically). Must be set explicitly when several
persistent features (cache-json, cache-redb, cache-redis) are
compiled in simultaneously.
Implementationsยง
Sourceยงimpl CacheConfig
impl CacheConfig
Sourcepub fn builder() -> CacheConfigBuilder<((), (), (), (), (), ())>
pub fn builder() -> CacheConfigBuilder<((), (), (), (), (), ())>
Create a builder for building CacheConfig.
On the builder, call .cache_dir(...), .redis_url(...)(optional), .video_ttl(...)(optional), .playlist_ttl(...)(optional), .download_ttl(...)(optional), .persistent_backend(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of CacheConfig.
Trait Implementationsยง
Sourceยงimpl Clone for CacheConfig
impl Clone for CacheConfig
Sourceยงfn clone(&self) -> CacheConfig
fn clone(&self) -> CacheConfig
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSourceยงimpl Debug for CacheConfig
impl Debug for CacheConfig
Auto Trait Implementationsยง
impl Freeze for CacheConfig
impl RefUnwindSafe for CacheConfig
impl Send for CacheConfig
impl Sync for CacheConfig
impl Unpin for CacheConfig
impl UnsafeUnpin for CacheConfig
impl UnwindSafe for CacheConfig
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
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Sourceยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Sourceยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Sourceยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Anyโs vtable from &Traitโs.Sourceยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Anyโs vtable from &mut Traitโs.