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
impl SimpleCacheKeyBuilder
Sourcepub fn with_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_prefix(self, prefix: impl Into<String>) -> Self
设置前缀
Sourcepub fn with_tenant(self, tenant: impl Into<String>) -> Self
pub fn with_tenant(self, tenant: impl Into<String>) -> Self
设置租户
Sourcepub fn with_modular(self, modular: impl Into<String>) -> Self
pub fn with_modular(self, modular: impl Into<String>) -> Self
设置模块名
Sourcepub fn with_field(self, field: impl Into<String>) -> Self
pub fn with_field(self, field: impl Into<String>) -> Self
设置字段名
Sourcepub fn with_value_type(self, value_type: ValueType) -> Self
pub fn with_value_type(self, value_type: ValueType) -> Self
设置 value 类型
Sourcepub fn with_expire(self, expire: Duration) -> Self
pub fn with_expire(self, expire: Duration) -> Self
设置过期时间
Trait Implementations§
Source§impl CacheKeyBuilder for SimpleCacheKeyBuilder
impl CacheKeyBuilder for SimpleCacheKeyBuilder
Source§fn get_prefix(&self) -> Option<&str>
fn get_prefix(&self) -> Option<&str>
缓存前缀,用于区分项目、环境等
Source§fn get_tenant(&self) -> Option<&str>
fn get_tenant(&self) -> Option<&str>
租户 ID,用于区分租户
非租户模式返回 None
Source§fn get_modular(&self) -> Option<&str>
fn get_modular(&self) -> Option<&str>
服务模块名,用于区分后端服务、前端模块等
Source§fn get_value_type(&self) -> ValueType
fn get_value_type(&self) -> ValueType
缓存的 value 存储的类型
Source§fn get_expire(&self) -> Option<Duration>
fn get_expire(&self) -> Option<Duration>
缓存自动过期时间
Source§fn set_tenant_id(&mut self, _tenant_id: u64)
fn set_tenant_id(&mut self, _tenant_id: u64)
设置租户 ID(默认不做处理,子类可重写)
Source§fn get_pattern(&self) -> String
fn get_pattern(&self) -> String
获取通配符模式
Source§fn key(&self, uniques: &[&dyn ToString]) -> CacheKey
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
fn hash_field_key( &self, field: &dyn ToString, uniques: &[&dyn ToString], ) -> CacheHashKey
构建 Redis 类型的 hash cache key(带 field) Read more
Source§impl Clone for SimpleCacheKeyBuilder
impl Clone for SimpleCacheKeyBuilder
Source§fn clone(&self) -> SimpleCacheKeyBuilder
fn clone(&self) -> SimpleCacheKeyBuilder
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 moreAuto Trait Implementations§
impl Freeze for SimpleCacheKeyBuilder
impl RefUnwindSafe for SimpleCacheKeyBuilder
impl Send for SimpleCacheKeyBuilder
impl Sync for SimpleCacheKeyBuilder
impl Unpin for SimpleCacheKeyBuilder
impl UnwindSafe for SimpleCacheKeyBuilder
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