pub struct RedisConfig {
pub host: String,
pub port: u16,
pub password: String,
pub select: u32,
pub timeout: Duration,
pub expire: Option<Duration>,
pub persistent: bool,
pub prefix: String,
pub tag_prefix: String,
}Expand description
Redis 缓存配置(对齐 PHP think\cache\driver\Redis::$options)
PHP 默认配置(Redis.php 第 33-44 行):
protected $options = [
'host' => '127.0.0.1',
'port' => 6379,
'password' => '',
'select' => 0,
'timeout' => 0,
'expire' => 0,
'persistent' => false,
'prefix' => '',
'tag_prefix' => 'tag:',
'serialize' => [],
];Fields§
§host: StringRedis 主机地址(对齐 PHP host)
port: u16Redis 端口(对齐 PHP port)
password: StringRedis 密码(对齐 PHP password,空字符串表示无密码)
select: u32Redis db 索引(对齐 PHP select)
timeout: Duration连接超时(对齐 PHP timeout,Duration::ZERO 表示无超时)
expire: Option<Duration>默认过期时间(对齐 PHP expire,None 表示永不过期)
persistent: bool是否使用持久连接(对齐 PHP persistent)
prefix: Stringkey 前缀(对齐 PHP prefix)
tag_prefix: Stringtag 前缀(对齐 PHP tag_prefix)
Implementations§
Source§impl RedisConfig
impl RedisConfig
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 RedisConfig
impl Clone for RedisConfig
Source§fn clone(&self) -> RedisConfig
fn clone(&self) -> RedisConfig
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 RedisConfig
impl Debug for RedisConfig
Auto Trait Implementations§
impl Freeze for RedisConfig
impl RefUnwindSafe for RedisConfig
impl Send for RedisConfig
impl Sync for RedisConfig
impl Unpin for RedisConfig
impl UnsafeUnpin for RedisConfig
impl UnwindSafe for RedisConfig
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