MyGit

0.11.0

redis-rs/redis-rs

版本发布时间: 2019-10-15 03:32:38

redis-rs/redis-rs最新发布版本:redis-0.27.4(2024-10-10 02:59:20)

This release includes all fixes & improvements from the two beta releases listed below. This release contains breaking changes.

Fixes and improvements

BREAKING CHANGES

Renamed the async module to aio (#189)

async is a reserved keyword in Rust 2018, so this avoids the need to write r#async in it.

Old code:

use redis::async::SharedConnection;

New code:

use redis::aio::SharedConnection;

The trait ToRedisArgs was changed (#165)

ToRedisArgs has been changed to take take an instance of RedisWrite instead of Vec<Vec<u8>>. Use the write_arg method instead of Vec::push.

Minimum Rust version is now 1.26 (#165)

Upgrade your compiler. impl Iterator is used, requiring a more recent version of the Rust compiler.

iter now takes self by value (#165)

iter now takes self by value instead of cloning self inside the method.

Old code:

let mut iter : redis::Iter<isize> = cmd.arg("my_set").cursor_arg(0).iter(&con).unwrap();

New code:

let mut iter : redis::Iter<isize> = cmd.arg("my_set").cursor_arg(0).clone().iter(&con).unwrap();

(The above line calls clone().)

A mutable connection object is now required (#148)

We removed the internal usage of RefCell and Cell and instead require a mutable reference, &mut ConnectionLike, on all command calls.

Old code:

let client = redis::Client::open("redis://127.0.0.1/")?;
let con = client.get_connection()?;
redis::cmd("SET").arg("my_key").arg(42).execute(&con);

New code:

let client = redis::Client::open("redis://127.0.0.1/")?;
let mut con = client.get_connection()?;
redis::cmd("SET").arg("my_key").arg(42).execute(&mut con);

Due to this, transaction has changed. The callback now also receives a mutable reference to the used connection.

Old code:

let client = redis::Client::open("redis://127.0.0.1/").unwrap();
let con = client.get_connection().unwrap();
let key = "the_key";
let (new_val,) : (isize,) = redis::transaction(&con, &[key], |pipe| {
    let old_val : isize = con.get(key)?;
    pipe
        .set(key, old_val + 1).ignore()
        .get(key).query(&con)
})?;

New code:

let client = redis::Client::open("redis://127.0.0.1/").unwrap();
let mut con = client.get_connection().unwrap();
let key = "the_key";
let (new_val,) : (isize,) = redis::transaction(&mut con, &[key], |con, pipe| {
    let old_val : isize = con.get(key)?;
    pipe
        .set(key, old_val + 1).ignore()
        .get(key).query(&con)
})?;

Remove rustc-serialize feature (#200)

We removed serialization to/from JSON. The underlying library is deprecated for a long time.

Old code in Cargo.toml:

[dependencies.redis]
version = "0.9.1"
features = ["with-rustc-json"]

There's no replacement for the feature. Use serde and handle the serialization/deserialization in your own code.

Remove with-unix-sockets feature (#201)

We removed the Unix socket feature. It is now always enabled. We also removed auto-detection.

Old code in Cargo.toml:

[dependencies.redis]
version = "0.9.1"
features = ["with-unix-sockets"]

There's no replacement for the feature. Unix sockets will continue to work by default.

相关地址:原始地址 下载(tar) 下载(zip)

查看:2019-10-15发行的版本