[−][src]Struct darkredis::Connection
A connection to Redis. Copying is cheap as the inner type is a simple, futures-aware, Arc<Mutex>
, and will
not create a new connection. Use a ConnectionPool
if you want to use pooled conections.
Every convenience function can work with any kind of data as long as it can be converted into bytes.
Methods
impl Connection
[src]
pub async fn connect<'_, A>(
address: A,
password: Option<&'_ str>
) -> Result<Self> where
A: ToSocketAddrs,
[src]
address: A,
password: Option<&'_ str>
) -> Result<Self> where
A: ToSocketAddrs,
Connect to a Redis instance running at address
.
pub async fn run_commands<'_, '_>(
&'_ mut self,
command: CommandList<'_>
) -> Result<Vec<Value>>
[src]
&'_ mut self,
command: CommandList<'_>
) -> Result<Vec<Value>>
Run a series of commands on this connection
pub async fn run_command<'_, '_>(
&'_ mut self,
command: Command<'_>
) -> Result<Value>
[src]
&'_ mut self,
command: Command<'_>
) -> Result<Value>
Run a single command on this connection
pub async fn set<'_, K, D>(&'_ mut self, key: K, data: D) -> Result<()> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
D: AsRef<[u8]>,
Convenience function for the Redis command SET
pub async fn set_with_expiry<'_, K, D>(
&'_ mut self,
key: K,
data: D,
expiry: Duration
) -> Result<()> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
[src]
&'_ mut self,
key: K,
data: D,
expiry: Duration
) -> Result<()> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
Convenience function for the Redis command SET, with an expiry time.
pub async fn del<'_, K>(&'_ mut self, key: K) -> Result<()> where
K: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
Convenience function for the Redis command DEL
pub async fn get<'_, D>(&'_ mut self, key: D) -> Result<Option<Vec<u8>>> where
D: AsRef<[u8]>,
[src]
D: AsRef<[u8]>,
Convenience function for the Redis command GET
pub async fn lpush<'_, K, D>(&'_ mut self, key: K, data: D) -> Result<isize> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
D: AsRef<[u8]>,
Convenience function for the Redis command LPUSH
pub async fn lpush_slice<'_, '_, K, D>(
&'_ mut self,
key: K,
data: &'_ [D]
) -> Result<isize> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
[src]
&'_ mut self,
key: K,
data: &'_ [D]
) -> Result<isize> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
Like lpush, but push multiple values through a slice
pub async fn rpush<'_, K, D>(&'_ mut self, key: K, data: D) -> Result<isize> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
D: AsRef<[u8]>,
Convenience function for the Redis command RPUSH
pub async fn rpush_slice<'_, '_, K, D>(
&'_ mut self,
key: K,
data: &'_ [D]
) -> Result<isize> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
[src]
&'_ mut self,
key: K,
data: &'_ [D]
) -> Result<isize> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
Like rpush, but push multiple values through a slice
pub async fn lpop<'_, K>(&'_ mut self, key: K) -> Result<Option<Vec<u8>>> where
K: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
Convenience function for the Redis command LPOP
pub async fn rpop<'_, K>(&'_ mut self, key: K) -> Result<Option<Vec<u8>>> where
K: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
Convenience function for the Redis command RPOP
pub async fn lrange<'_, K>(
&'_ mut self,
key: K,
from: isize,
to: isize
) -> Result<Vec<Vec<u8>>> where
K: AsRef<[u8]>,
[src]
&'_ mut self,
key: K,
from: isize,
to: isize
) -> Result<Vec<Vec<u8>>> where
K: AsRef<[u8]>,
Convenience function for the Redis command LRANGE
pub async fn llen<'_, K>(&'_ mut self, key: K) -> Result<Option<isize>> where
K: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
Convenience function for the Redis command LLEN
pub async fn lset<'_, K, D>(
&'_ mut self,
key: K,
index: usize,
value: D
) -> Result<()> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
[src]
&'_ mut self,
key: K,
index: usize,
value: D
) -> Result<()> where
K: AsRef<[u8]>,
D: AsRef<[u8]>,
Convenience function for LSET.
pub async fn ltrim<'_, K>(
&'_ mut self,
key: K,
start: usize,
stop: usize
) -> Result<()> where
K: AsRef<[u8]>,
[src]
&'_ mut self,
key: K,
start: usize,
stop: usize
) -> Result<()> where
K: AsRef<[u8]>,
Convenience function for LTRIM
Trait Implementations
impl Clone for Connection
[src]
fn clone(&self) -> Connection
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl Sync for Connection
impl Send for Connection
impl Unpin for Connection
impl !RefUnwindSafe for Connection
impl !UnwindSafe for Connection
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,