Struct redis_driver::Database
source · [−]pub struct Database { /* private fields */ }
Implementations
sourceimpl Database
impl Database
Set of Redis commands related to a specific database
sourcepub fn get_database(&self) -> usize
pub fn get_database(&self) -> usize
The numeric identifier of this database
sourcepub fn send<'a>(
&'a self,
command: Command
) -> impl Future<Output = Result<Value>> + 'a
pub fn send<'a>(
&'a self,
command: Command
) -> impl Future<Output = Result<Value>> + 'a
Send an arbitrary command to the server.
This is used primarily intended for implementing high level commands API but may also be used to provide access to new features that lack a direct API.
Arguments
name
- Command name in uppercase.args
- Command arguments which can be provided as arrays (up to 4 elements) or vectors of BulkString.
Example
let connection = ConnectionMultiplexer::connect("127.0.0.1:6379").await?;
let database = connection.get_default_database();
let values: Vec<String> = database
.send(cmd("MGET").arg("key1").arg("key2").arg("key3").arg("key4"))
.await?
.into()?;
Trait Implementations
sourceimpl GenericCommands for Database
impl GenericCommands for Database
sourceimpl ListCommands for Database
impl ListCommands for Database
sourcefn lpush<'life0, 'async_trait, K, E>(
&'life0 self,
key: K,
elements: E
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
E: IntoArgs + Send,
K: 'async_trait,
E: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn lpush<'life0, 'async_trait, K, E>(
&'life0 self,
key: K,
elements: E
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
E: IntoArgs + Send,
K: 'async_trait,
E: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Insert all the specified values at the head of the list stored at key Read more
sourcefn lpop<'life0, 'async_trait, K, E>(
&'life0 self,
key: K,
count: usize
) -> Pin<Box<dyn Future<Output = Result<Vec<E>>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
E: FromValue,
K: 'async_trait,
E: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn lpop<'life0, 'async_trait, K, E>(
&'life0 self,
key: K,
count: usize
) -> Pin<Box<dyn Future<Output = Result<Vec<E>>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
E: FromValue,
K: 'async_trait,
E: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Removes and returns the first elements of the list stored at key. Read more
sourceimpl StringCommands for Database
impl StringCommands for Database
sourcefn append<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn append<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
If key already exists and is a string, this command appends the value at the end of the string. If key does not exist it is created and set as an empty string, so APPEND will be similar to SET in this special case. Read more
sourcefn decr<'life0, 'async_trait, K>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn decr<'life0, 'async_trait, K>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Decrements the number stored at key by one. Read more
sourcefn decrby<'life0, 'async_trait, K>(
&'life0 self,
key: K,
decrement: i64
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn decrby<'life0, 'async_trait, K>(
&'life0 self,
key: K,
decrement: i64
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Decrements the number stored at key by one. Read more
sourcefn get<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: FromValue,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn get<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: FromValue,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Get the value of key. Read more
sourcefn getdel<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: FromValue,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn getdel<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: FromValue,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Get the value of key and delete the key. Read more
sourcefn getex<K>(&self, key: K) -> GetEx<'_> where
K: Into<BulkString> + Send,
fn getex<K>(&self, key: K) -> GetEx<'_> where
K: Into<BulkString> + Send,
Get the value of key and optionally set its expiration. GETEX is similar to GET, but is a write command with additional options. Read more
sourcefn getrange<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
start: usize,
end: isize
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: FromValue,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn getrange<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
start: usize,
end: isize
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: FromValue,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). Read more
sourcefn getset<'life0, 'async_trait, K, V, R>(
&'life0 self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
R: FromValue,
K: 'async_trait,
V: 'async_trait,
R: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn getset<'life0, 'async_trait, K, V, R>(
&'life0 self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
R: FromValue,
K: 'async_trait,
V: 'async_trait,
R: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Atomically sets key to value and returns the old value stored at key. Returns an error when key exists but does not hold a string value. Any previous time to live associated with the key is discarded on successful SET operation. Read more
sourcefn incr<'life0, 'async_trait, K>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn incr<'life0, 'async_trait, K>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Increments the number stored at key by one. Read more
sourcefn incrby<'life0, 'async_trait, K>(
&'life0 self,
key: K,
increment: i64
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn incrby<'life0, 'async_trait, K>(
&'life0 self,
key: K,
increment: i64
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Increments the number stored at key by increment. Read more
sourcefn incrbyfloat<'life0, 'async_trait, K>(
&'life0 self,
key: K,
increment: f64
) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn incrbyfloat<'life0, 'async_trait, K>(
&'life0 self,
key: K,
increment: f64
) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Increment the string representing a floating point number stored at key by the specified increment. By using a negative increment value, the result is that the value stored at the key is decremented (by the obvious properties of addition). If the key does not exist, it is set to 0 before performing the operation. An error is returned if one of the following conditions occur: Read more
sourcefn lcs<K>(&self, key1: K, key2: K) -> Lcs<'_> where
K: Into<BulkString> + Send,
fn lcs<K>(&self, key1: K, key2: K) -> Lcs<'_> where
K: Into<BulkString> + Send,
The LCS command implements the longest common subsequence algorithm Read more
sourcefn mget<'a, 'async_trait, K, V>(
&'a self,
keys: K
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<V>>>> + Send + 'async_trait>> where
K: IntoArgs + Send + Sync,
V: FromValue,
'a: 'async_trait,
K: 'async_trait,
V: 'async_trait,
Self: 'async_trait,
fn mget<'a, 'async_trait, K, V>(
&'a self,
keys: K
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<V>>>> + Send + 'async_trait>> where
K: IntoArgs + Send + Sync,
V: FromValue,
'a: 'async_trait,
K: 'async_trait,
V: 'async_trait,
Self: 'async_trait,
Returns the values of all specified keys. Read more
sourcefn mset<'a, 'async_trait, K, V>(
&'a self,
items: &'a [(K, V)]
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
K: Into<BulkString> + Send + Sync + Copy,
V: Into<BulkString> + Send + Sync + Copy,
'a: 'async_trait,
K: 'async_trait,
V: 'async_trait,
Self: 'async_trait,
fn mset<'a, 'async_trait, K, V>(
&'a self,
items: &'a [(K, V)]
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
K: Into<BulkString> + Send + Sync + Copy,
V: Into<BulkString> + Send + Sync + Copy,
'a: 'async_trait,
K: 'async_trait,
V: 'async_trait,
Self: 'async_trait,
Sets the given keys to their respective values. Read more
sourcefn msetnx<'a, 'async_trait, K, V>(
&'a self,
items: &'a [(K, V)]
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
K: Into<BulkString> + Send + Sync + Copy,
V: Into<BulkString> + Send + Sync + Copy,
'a: 'async_trait,
K: 'async_trait,
V: 'async_trait,
Self: 'async_trait,
fn msetnx<'a, 'async_trait, K, V>(
&'a self,
items: &'a [(K, V)]
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
K: Into<BulkString> + Send + Sync + Copy,
V: Into<BulkString> + Send + Sync + Copy,
'a: 'async_trait,
K: 'async_trait,
V: 'async_trait,
Self: 'async_trait,
Sets the given keys to their respective values. MSETNX will not perform any operation at all even if just a single key already exists. Read more
sourcefn psetex<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
milliseconds: u64,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn psetex<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
milliseconds: u64,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
sourcefn set<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn set<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Set key to hold the string value. Read more
sourcefn set_with_options<K, V>(&self, key: K, value: V) -> SetWithOptions<'_> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
fn set_with_options<K, V>(&self, key: K, value: V) -> SetWithOptions<'_> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
Set key to hold the string value. Read more
sourcefn setex<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
seconds: u64,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn setex<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
seconds: u64,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Set key to hold the string value and set key to timeout after a given number of seconds. Read more
sourcefn setnx<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn setnx<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Set key to hold string value if key does not exist. Read more
sourcefn setrange<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
offset: usize,
value: V
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn setrange<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
offset: usize,
value: V
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where
K: Into<BulkString> + Send,
V: Into<BulkString> + Send,
K: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
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> 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