Struct merino_cache::redis::SimpleRedisLock
source · [−]pub struct SimpleRedisLock {
connection: ConnectionManager,
}
Expand description
Very simple Redis Lock mechanism.
Fields
connection: ConnectionManager
connection handler
Implementations
sourceimpl SimpleRedisLock
impl SimpleRedisLock
sourcefn lock_key(key: &str) -> String
fn lock_key(key: &str) -> String
Generate a lock identifier key.
This is a VERY simple locking mechanism. The only bit of fancy is that it will expire, allowing for “stuck” queries to eventually resolve.
sourceasync fn is_locked(&mut self, key: &str) -> Result<bool, SuggestError>
async fn is_locked(&mut self, key: &str) -> Result<bool, SuggestError>
See if a record update is locked for pending update.
This does not check lock value, only if a lock exists.
sourceasync fn lock(
&mut self,
key: &str,
default_lock_timeout: Duration
) -> Result<Option<String>, SuggestError>
async fn lock(
&mut self,
key: &str,
default_lock_timeout: Duration
) -> Result<Option<String>, SuggestError>
Generate a lock, this returns a unique Lock value string to ensure that only the thread with the most recent “lock” can write to this key.
This will return a None if the lock could not be created.
sourceasync fn write_if_locked(
&mut self,
key: &str,
lock: &str,
to_store: RedisSuggestions,
ttl: Duration
) -> Result<(), SuggestError>
async fn write_if_locked(
&mut self,
key: &str,
lock: &str,
to_store: RedisSuggestions,
ttl: Duration
) -> Result<(), SuggestError>
Only write a given item if the lock matches the value we have on hand.
Silently fails and discards if the lock is invalid.
Trait Implementations
sourceimpl Clone for SimpleRedisLock
impl Clone for SimpleRedisLock
sourcefn clone(&self) -> SimpleRedisLock
fn clone(&self) -> SimpleRedisLock
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl From<&ConnectionManager> for SimpleRedisLock
impl From<&ConnectionManager> for SimpleRedisLock
sourcefn from(connection: &ConnectionManager) -> Self
fn from(connection: &ConnectionManager) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl !RefUnwindSafe for SimpleRedisLock
impl Send for SimpleRedisLock
impl Sync for SimpleRedisLock
impl Unpin for SimpleRedisLock
impl !UnwindSafe for SimpleRedisLock
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more