pub struct OxcacheConfigBuilder { /* private fields */ }Expand description
OxcacheConfig 构建器
使用 Builder 模式提供链式 API 构建配置。 支持 feature-gated 配置:
- LayerConfig: 需要 l1-moka feature
- confers 扩展: 需要 confers feature
§示例
use oxcache::{OxcacheConfigBuilder, GlobalConfig, ServiceConfig, CacheType};
let config = OxcacheConfigBuilder::new()
.with_global(GlobalConfig::default())
.with_service("api", ServiceConfig::two_level())
.build();Implementations§
Source§impl OxcacheConfigBuilder
impl OxcacheConfigBuilder
Sourcepub fn with_global(self, global: GlobalConfig) -> Self
pub fn with_global(self, global: GlobalConfig) -> Self
设置全局配置
Sourcepub fn with_service(self, name: &str, service: ServiceConfig) -> Self
pub fn with_service(self, name: &str, service: ServiceConfig) -> Self
添加或更新服务配置
Sourcepub fn with_services(self, services: HashMap<String, ServiceConfig>) -> Self
pub fn with_services(self, services: HashMap<String, ServiceConfig>) -> Self
添加多个服务配置
Sourcepub fn with_layer(self, layer: LayerConfig) -> Self
pub fn with_layer(self, layer: LayerConfig) -> Self
设置层级配置(需要 l1-moka feature)
Sourcepub fn build(self) -> OxcacheConfig
pub fn build(self) -> OxcacheConfig
Sourcepub fn available_features(&self) -> Vec<&'static str>
pub fn available_features(&self) -> Vec<&'static str>
获取当前配置的特征信息
Trait Implementations§
Source§impl Clone for OxcacheConfigBuilder
impl Clone for OxcacheConfigBuilder
Source§fn clone(&self) -> OxcacheConfigBuilder
fn clone(&self) -> OxcacheConfigBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OxcacheConfigBuilder
impl Debug for OxcacheConfigBuilder
Source§impl Default for OxcacheConfigBuilder
impl Default for OxcacheConfigBuilder
Source§fn default() -> OxcacheConfigBuilder
fn default() -> OxcacheConfigBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OxcacheConfigBuilder
impl RefUnwindSafe for OxcacheConfigBuilder
impl Send for OxcacheConfigBuilder
impl Sync for OxcacheConfigBuilder
impl Unpin for OxcacheConfigBuilder
impl UnwindSafe for OxcacheConfigBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more