Function ntex_redis::cmd::LPop[][src]

pub fn LPop<T>(key: T) -> BulkOutputCommand where
    BulkString: From<T>, 
Expand description

LPOP redis command

Removes and returns the first element of the list stored at key.

use ntex_redis::{cmd, RedisConnector};

#[ntex::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let redis = RedisConnector::new("127.0.0.1:6379").connect().await?;
    let key = gen_random_key();

    // create list with one value
    redis.exec(cmd::LPush(&key, "value")).await?;

    // pop first elements from the list
    let value = redis.exec(cmd::LPop(&key)).await?;

    assert_eq!(value.unwrap(), "value");
    Ok(())
}