pub struct WithCacheConfig {
pub key: Option<String>,
pub expire: Option<Duration>,
pub tag: Option<String>,
}Expand description
PHP 关联缓存配置(对齐 [$key, $expire, $tag] 三元组)
对齐 PHP withCache($relation, $key, $expire, $tag) 中每个关联的配置三元组:
$this->options['with_cache'][$relation] = [$key, $expire, $tag];§字段说明
key:缓存键(None对齐 PHP$key = true自动生成;Some(s)对齐自定义 key)expire:过期时间(None对齐 PHP$expire = null永不过期)tag:缓存标签(None对齐 PHP$tag = null,使用默认表名)
§示例
ⓘ
use sz_rust_core::relation::cache::{WithCacheConfig, php_with_cache_config};
use std::time::Duration;
// 等价 PHP: withCache('orders', true, 3600, null)
let config = php_with_cache_config(None, Some(Duration::from_secs(3600)), None);
assert_eq!(config.key, None);
assert_eq!(config.expire, Some(Duration::from_secs(3600)));
assert_eq!(config.tag, None);Fields§
§key: Option<String>缓存键(None = 自动生成,对齐 PHP $key = true)
expire: Option<Duration>过期时间(None = 永不过期,对齐 PHP $expire = null)
tag: Option<String>缓存标签(None = 使用默认表名,对齐 PHP $tag = null)
Implementations§
Source§impl WithCacheConfig
impl WithCacheConfig
Sourcepub fn is_auto_key(&self) -> bool
pub fn is_auto_key(&self) -> bool
是否使用自动生成的缓存键(对齐 PHP $key = true)
Sourcepub fn is_permanent(&self) -> bool
pub fn is_permanent(&self) -> bool
是否永不过期(对齐 PHP $expire = null)
Sourcepub fn is_default_tag(&self) -> bool
pub fn is_default_tag(&self) -> bool
是否使用默认 tag 即表名(对齐 PHP $tag = null)
Trait Implementations§
Source§impl Clone for WithCacheConfig
impl Clone for WithCacheConfig
Source§fn clone(&self) -> WithCacheConfig
fn clone(&self) -> WithCacheConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 WithCacheConfig
impl Debug for WithCacheConfig
Source§impl Default for WithCacheConfig
impl Default for WithCacheConfig
Source§fn default() -> WithCacheConfig
fn default() -> WithCacheConfig
Returns the “default value” for a type. Read more
impl Eq for WithCacheConfig
Source§impl PartialEq for WithCacheConfig
impl PartialEq for WithCacheConfig
impl StructuralPartialEq for WithCacheConfig
Auto Trait Implementations§
impl Freeze for WithCacheConfig
impl RefUnwindSafe for WithCacheConfig
impl Send for WithCacheConfig
impl Sync for WithCacheConfig
impl Unpin for WithCacheConfig
impl UnsafeUnpin for WithCacheConfig
impl UnwindSafe for WithCacheConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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