pub struct MockRedisBackend { /* private fields */ }Expand description
Mock Redis 后端(用 HashMap 模拟 Redis 行为)
用于测试和开发环境,不需要真实 Redis 服务器。
§模拟行为
- KV 存储:
HashMap<String, (Vec<u8>, Option<Instant>)>— value + expires_at - Set 存储:
HashMap<String, HashSet<String>> - TTL 过期:
get/exists/incr_by/decr_by时检查过期 - INCRBY:key 不存在时初始化为 0,非数字时返回错误(对齐 Redis 行为)
Implementations§
Trait Implementations§
Source§impl Default for MockRedisBackend
impl Default for MockRedisBackend
Auto Trait Implementations§
impl !Freeze for MockRedisBackend
impl !RefUnwindSafe for MockRedisBackend
impl Send for MockRedisBackend
impl Sync for MockRedisBackend
impl Unpin for MockRedisBackend
impl UnsafeUnpin for MockRedisBackend
impl UnwindSafe for MockRedisBackend
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> 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