Function ntex_redis::cmd::LIndex [−][src]
pub fn LIndex<T>(key: T, index: i64) -> BulkOutputCommand where
BulkString: From<T>,
LINDEX redis command
Returns the element at index index in 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?; // get value by index let value = redis.exec(cmd::LIndex(&key, 0)).await?; assert_eq!(value.unwrap(), "value"); Ok(()) }