|
@@ -307,7 +307,7 @@ pub async fn setex(conn: &Connection, args: &[Bytes]) -> Result<Value, Error> {
|
|
|
|
|
|
Ok(conn
|
|
|
.db()
|
|
|
- .set(&args[1], Value::Blob(args[2].to_owned()), Some(ttl)))
|
|
|
+ .set(&args[1], Value::Blob(args[3].to_owned()), Some(ttl)))
|
|
|
}
|
|
|
|
|
|
/// Set key to hold string value if key does not exist. In that case, it is
|
|
@@ -655,6 +655,17 @@ mod test {
|
|
|
}
|
|
|
|
|
|
#[tokio::test]
|
|
|
+ async fn setex() {
|
|
|
+ let c = create_connection();
|
|
|
+ assert_eq!(
|
|
|
+ Ok(Value::Ok),
|
|
|
+ run_command(&c, &["setex", "foo", "10", "bar"]).await
|
|
|
+ );
|
|
|
+ assert_eq!(Ok("bar".into()), run_command(&c, &["get", "foo"]).await);
|
|
|
+ assert_eq!(Ok(9.into()), run_command(&c, &["ttl", "foo"]).await);
|
|
|
+ }
|
|
|
+
|
|
|
+ #[tokio::test]
|
|
|
async fn wrong_type() {
|
|
|
let c = create_connection();
|
|
|
let _ = run_command(&c, &["hset", "xxx", "key", "foo"]).await;
|