[][src]Struct darkredis::Connection

pub struct Connection { /* fields omitted */ }

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]

Connect to a Redis instance running at address.

pub async fn run_commands<'_, '_>(
    &'_ mut self,
    command: CommandList<'_>
) -> Result<Vec<Value>>
[src]

Run a series of commands on this connection

pub async fn run_command<'_, '_>(
    &'_ mut self,
    command: Command<'_>
) -> Result<Value>
[src]

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]

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]

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]

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]

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]

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]

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]

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]

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]

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]

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]

Convenience function for the Redis command LRANGE

pub async fn llen<'_, K>(&'_ mut self, key: K) -> Result<Option<isize>> where
    K: AsRef<[u8]>, 
[src]

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]

Convenience function for LSET.

pub async fn ltrim<'_, K>(
    &'_ mut self,
    key: K,
    start: usize,
    stop: usize
) -> Result<()> where
    K: AsRef<[u8]>, 
[src]

Convenience function for LTRIM

Trait Implementations

impl Clone for Connection[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T