pub struct MemcachedConfig {
pub host: String,
pub port: u16,
pub expire: Option<Duration>,
pub prefix: String,
pub tag_prefix: String,
pub timeout: Duration,
pub weight: u32,
}Expand description
Memcached 配置(对齐 PHP think\cache\driver\Memcached 的 $options)
PHP 配置示例:
'memcached' => [
'host' => '127.0.0.1',
'port' => 11211,
'expire' => 3600,
'prefix' => '',
'timeout' => 1000,
'weight' => 0,
],Fields§
§host: StringMemcached 主机地址(对齐 PHP host)
port: u16Memcached 端口(对齐 PHP port,默认 11211)
expire: Option<Duration>默认过期时间(对齐 PHP expire,None 表示使用最大 TTL 30 天)
prefix: Stringkey 前缀(对齐 PHP prefix,客户端实现)
tag_prefix: Stringtag 前缀(对齐 PHP tag_prefix)
timeout: Duration连接超时(对齐 PHP timeout,毫秒;Duration::ZERO 表示无超时)
weight: u32服务器权重(对齐 PHP weight,多服务器场景使用)
Implementations§
Source§impl MemcachedConfig
impl MemcachedConfig
Sourcepub fn with_prefix(prefix: impl Into<String>) -> Self
pub fn with_prefix(prefix: impl Into<String>) -> Self
创建带前缀的配置(便捷方法)
Sourcepub fn with_expire(expire: Duration) -> Self
pub fn with_expire(expire: Duration) -> Self
创建带默认 TTL 的配置(便捷方法)
Trait Implementations§
Source§impl Clone for MemcachedConfig
impl Clone for MemcachedConfig
Source§fn clone(&self) -> MemcachedConfig
fn clone(&self) -> MemcachedConfig
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 MemcachedConfig
impl Debug for MemcachedConfig
Auto Trait Implementations§
impl Freeze for MemcachedConfig
impl RefUnwindSafe for MemcachedConfig
impl Send for MemcachedConfig
impl Sync for MemcachedConfig
impl Unpin for MemcachedConfig
impl UnsafeUnpin for MemcachedConfig
impl UnwindSafe for MemcachedConfig
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<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