SimpleCacheKeyBuilder

Struct SimpleCacheKeyBuilder 

Source
pub struct SimpleCacheKeyBuilder {
    pub prefix: Option<String>,
    pub tenant: Option<String>,
    pub modular: Option<String>,
    pub table: String,
    pub field: Option<String>,
    pub value_type: ValueType,
    pub expire: Option<Duration>,
}
Expand description

简单的缓存键构建器实现

用于快速构建缓存键,无需实现完整的 trait

Fields§

§prefix: Option<String>§tenant: Option<String>§modular: Option<String>§table: String§field: Option<String>§value_type: ValueType§expire: Option<Duration>

Implementations§

Source§

impl SimpleCacheKeyBuilder

Source

pub fn new(table: impl Into<String>) -> Self

创建新的缓存键构建器

Source

pub fn with_prefix(self, prefix: impl Into<String>) -> Self

设置前缀

Source

pub fn with_tenant(self, tenant: impl Into<String>) -> Self

设置租户

Source

pub fn with_modular(self, modular: impl Into<String>) -> Self

设置模块名

Source

pub fn with_field(self, field: impl Into<String>) -> Self

设置字段名

Source

pub fn with_value_type(self, value_type: ValueType) -> Self

设置 value 类型

Source

pub fn with_expire(self, expire: Duration) -> Self

设置过期时间

Trait Implementations§

Source§

impl CacheKeyBuilder for SimpleCacheKeyBuilder

Source§

fn get_prefix(&self) -> Option<&str>

缓存前缀,用于区分项目、环境等
Source§

fn get_tenant(&self) -> Option<&str>

租户 ID,用于区分租户 非租户模式返回 None
Source§

fn get_modular(&self) -> Option<&str>

服务模块名,用于区分后端服务、前端模块等
Source§

fn get_table(&self) -> &str

key 的业务类型,用于区分表(必填)
Source§

fn get_field(&self) -> Option<&str>

key 的字段名,用于区分字段
Source§

fn get_value_type(&self) -> ValueType

缓存的 value 存储的类型
Source§

fn get_expire(&self) -> Option<Duration>

缓存自动过期时间
Source§

fn set_tenant_id(&mut self, _tenant_id: u64)

设置租户 ID(默认不做处理,子类可重写)
Source§

fn get_pattern(&self) -> String

获取通配符模式
Source§

fn key(&self, uniques: &[&dyn ToString]) -> CacheKey

构建通用 KV 模式的 cache key 兼容 redis 和 caffeine Read more
Source§

fn hash_field_key( &self, field: &dyn ToString, uniques: &[&dyn ToString], ) -> CacheHashKey

构建 Redis 类型的 hash cache key(带 field) Read more
Source§

fn hash_key(&self, uniques: &[&dyn ToString]) -> CacheHashKey

构建 Redis 类型的 hash cache key(无 field) Read more
Source§

fn build_key(&self, uniques: &[&dyn ToString]) -> String

根据动态参数拼接 key Read more
Source§

impl Clone for SimpleCacheKeyBuilder

Source§

fn clone(&self) -> SimpleCacheKeyBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SimpleCacheKeyBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,