pub struct RedisDistributedLock { /* private fields */ }Expand description
Redis 简单分布式锁。
锁语义:
- 加锁:
SET key value NX EX lease(value 为唯一标识,支持重入判断) - 释放:Lua 脚本校验 value 后 DEL(防止误删他人锁)
Implementations§
Source§impl RedisDistributedLock
impl RedisDistributedLock
Sourcepub fn with_key(
client: Client,
key: impl Into<String>,
lease_milliseconds: i64,
) -> Result<Self, String>
pub fn with_key( client: Client, key: impl Into<String>, lease_milliseconds: i64, ) -> Result<Self, String>
Sourcepub fn lease_milliseconds(&self) -> i64
pub fn lease_milliseconds(&self) -> i64
返回锁租约时长(毫秒)。
Trait Implementations§
Source§impl Clone for RedisDistributedLock
impl Clone for RedisDistributedLock
Source§fn clone(&self) -> RedisDistributedLock
fn clone(&self) -> RedisDistributedLock
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 moreAuto Trait Implementations§
impl Freeze for RedisDistributedLock
impl RefUnwindSafe for RedisDistributedLock
impl Send for RedisDistributedLock
impl Sync for RedisDistributedLock
impl Unpin for RedisDistributedLock
impl UnsafeUnpin for RedisDistributedLock
impl UnwindSafe for RedisDistributedLock
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