Skip to content

Commit

Permalink
Merge branch 'main-upstream' into pull-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
nihohit committed Dec 6, 2023
2 parents 3e9cc5c + 37ba561 commit f9e8847
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 48 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The crate is called `redis` and you can depend on it via cargo:

```ini
[dependencies]
redis = "0.23.4"
redis = "0.24.0"
```

Documentation on the library can be found at
Expand Down Expand Up @@ -59,10 +59,10 @@ To enable asynchronous clients, enable the relevant feature in your Cargo.toml,

```
# if you use tokio
redis = { version = "0.23.4", features = ["tokio-comp"] }
redis = { version = "0.24.0", features = ["tokio-comp"] }
# if you use async-std
redis = { version = "0.23.4", features = ["async-std-comp"] }
redis = { version = "0.24.0", features = ["async-std-comp"] }
```

## TLS Support
Expand All @@ -73,25 +73,25 @@ Currently, `native-tls` and `rustls` are supported.
To use `native-tls`:

```
redis = { version = "0.23.4", features = ["tls-native-tls"] }
redis = { version = "0.24.0", features = ["tls-native-tls"] }
# if you use tokio
redis = { version = "0.23.4", features = ["tokio-native-tls-comp"] }
redis = { version = "0.24.0", features = ["tokio-native-tls-comp"] }
# if you use async-std
redis = { version = "0.23.4", features = ["async-std-native-tls-comp"] }
redis = { version = "0.24.0", features = ["async-std-native-tls-comp"] }
```

To use `rustls`:

```
redis = { version = "0.23.4", features = ["tls-rustls"] }
redis = { version = "0.24.0", features = ["tls-rustls"] }
# if you use tokio
redis = { version = "0.23.4", features = ["tokio-rustls-comp"] }
redis = { version = "0.24.0", features = ["tokio-rustls-comp"] }
# if you use async-std
redis = { version = "0.23.4", features = ["async-std-rustls-comp"] }
redis = { version = "0.24.0", features = ["async-std-rustls-comp"] }
```

With `rustls`, you can add the following feature flags on top of other feature flags to enable additional features:
Expand All @@ -117,7 +117,7 @@ let client = redis::Client::open("rediss://127.0.0.1/#insecure")?;

Support for Redis Cluster can be enabled by enabling the `cluster` feature in your Cargo.toml:

`redis = { version = "0.23.4", features = [ "cluster"] }`
`redis = { version = "0.24.0", features = [ "cluster"] }`

Then you can simply use the `ClusterClient`, which accepts a list of available nodes. Note
that only one node in the cluster needs to be specified when instantiating the client, though
Expand All @@ -140,7 +140,7 @@ fn fetch_an_integer() -> String {
Async Redis Cluster support can be enabled by enabling the `cluster-async` feature, along
with your preferred async runtime, e.g.:

`redis = { version = "0.23.4", features = [ "cluster-async", "tokio-std-comp" ] }`
`redis = { version = "0.24.0", features = [ "cluster-async", "tokio-std-comp" ] }`

```rust
use redis::cluster::ClusterClient;
Expand All @@ -160,7 +160,7 @@ async fn fetch_an_integer() -> String {

Support for the RedisJSON Module can be enabled by specifying "json" as a feature in your Cargo.toml.

`redis = { version = "0.23.4", features = ["json"] }`
`redis = { version = "0.24.0", features = ["json"] }`

Then you can simply import the `JsonCommands` trait which will add the `json` commands to all Redis Connections (not to be confused with just `Commands` which only adds the default commands)

Expand Down
7 changes: 2 additions & 5 deletions redis-test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
### 0.2.4 (2023-11-26)
* Track redis 0.23.4 release

#### Changes
* Remove redis version from Cargo. (#943)
### 0.3.0 (2023-12-05)
* Track redis 0.24.0 release

### 0.2.3 (2023-09-01)

Expand Down
6 changes: 3 additions & 3 deletions redis-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "redis-test"
version = "0.2.4"
version = "0.3.0"
edition = "2021"
description = "Testing helpers for the `redis` crate"
homepage = "https://github.com/redis-rs/redis-rs"
Expand All @@ -13,7 +13,7 @@ rust-version = "1.65"
bench = false

[dependencies]
redis = { path = "../redis" }
redis = { version = "0.24.0", path = "../redis" }

bytes = { version = "1", optional = true }
futures = { version = "0.3", optional = true }
Expand All @@ -22,5 +22,5 @@ futures = { version = "0.3", optional = true }
aio = ["futures", "redis/aio"]

[dev-dependencies]
redis = { path = "../redis", features = ["aio", "tokio-comp"] }
redis = { version = "0.24.0", path = "../redis", features = ["aio", "tokio-comp"] }
tokio = { version = "1", features = ["rt", "macros", "rt-multi-thread", "time"] }
20 changes: 14 additions & 6 deletions redis/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
### 0.23.4 (2023-11-26)

### 0.24.0 (2023-12-05)

#### Features
* Support Mutual TLS ([#858](https://github.com/redis-rs/redis-rs/pull/858) @sp-angel)
* **Breaking change**: Support Mutual TLS ([#858](https://github.com/redis-rs/redis-rs/pull/858) @sp-angel)
* Implement `FromRedisValue` for `Box<[T]>` and `Arc<[T]>` ([#799](https://github.com/redis-rs/redis-rs/pull/799) @JOT85)
* Sync Cluster: support multi-slot operations. ([#967](https://github.com/redis-rs/redis-rs/pull/967))
* Execute multi-node requests using try_request. ([#919](https://github.com/redis-rs/redis-rs/pull/919))
Expand All @@ -11,13 +10,19 @@
* Add `tcp_nodelay` feature ([#941](https://github.com/redis-rs/redis-rs/pull/941) @PureWhiteWu)
* Add support for multi-shard commands. ([#900](https://github.com/redis-rs/redis-rs/pull/900))


#### Changes
* Order in usage of ClusterParams. ([#997](https://github.com/redis-rs/redis-rs/pull/997))
* **Breaking change**: Fix StreamId::contains_key signature ([#783](https://github.com/redis-rs/redis-rs/pull/783) @Ayush1325)
* **Breaking change**: Update Command expiration values to be an appropriate type ([#589](https://github.com/redis-rs/redis-rs/pull/589) @joshleeb)
* **Breaking change**: Bump aHash to v0.8.6 ([#966](https://github.com/redis-rs/redis-rs/pull/966) @aumetra)
* Fix features for `load_native_certs`. ([#996](https://github.com/redis-rs/redis-rs/pull/996))
* Revert redis-test versioning changes ([#993](https://github.com/redis-rs/redis-rs/pull/993))
* Tests: Add retries to test cluster creation ([#994](https://github.com/redis-rs/redis-rs/pull/994))
* Fix sync cluster behavior with transactions. ([#983](https://github.com/redis-rs/redis-rs/pull/983))
* Sync Pub/Sub - cache received pub/sub messages. ([#910](https://github.com/redis-rs/redis-rs/pull/910))
* Prefer routing to primary in a transaction. ([#986](https://github.com/redis-rs/redis-rs/pull/986))
* Accept iterator at `ClusterClient` initialization ([#987](https://github.com/redis-rs/redis-rs/pull/987) @ruanpetterson)
* Change timeouts from usize and isize to f64 ([#988](https://github.com/redis-rs/redis-rs/pull/988) @eythorhel19)
* **Breaking change**: Change timeouts from usize and isize to f64 ([#988](https://github.com/redis-rs/redis-rs/pull/988) @eythorhel19)
* Update minimal rust version to 1.6.5 ([#982](https://github.com/redis-rs/redis-rs/pull/982))
* Disable JSON module tests for redis 6.2.4. ([#980](https://github.com/redis-rs/redis-rs/pull/980))
* Add connection string examples ([#976](https://github.com/redis-rs/redis-rs/pull/976) @NuclearOreo)
Expand All @@ -33,8 +38,11 @@
* CI: Increase timeouts and use newer redis. ([#949](https://github.com/redis-rs/redis-rs/pull/949))
* Remove redis version from redis-test. ([#943](https://github.com/redis-rs/redis-rs/pull/943))

### 0.23.4 (2023-11-26)
**Yanked** -- Inadvertently introduced breaking changes (sorry!). The changes in this tag
have been pushed to 0.24.0.

### 0.23.4 (2023-09-01)
### 0.23.3 (2023-09-01)

Note that this release fixes a small regression in async Redis Cluster handling of the `PING` command.
Based on updated response aggregation logic in [#888](https://github.com/redis-rs/redis-rs/pull/888), it
Expand Down
4 changes: 2 additions & 2 deletions redis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "redis"
version = "0.23.4"
version = "0.24.0"
keywords = ["redis", "database"]
description = "Redis driver for Rust."
homepage = "https://github.com/redis-rs/redis-rs"
Expand Down Expand Up @@ -87,7 +87,7 @@ serde = { version = "1.0.82", optional = true }
serde_json = { version = "1.0.82", optional = true }

# Optional aHash support
ahash = { version = "0.7.6", optional = true }
ahash = { version = "0.8.6", optional = true }

tracing = "0.1"
futures-time = { version = "3.0.0", optional = true }
Expand Down
3 changes: 3 additions & 0 deletions redis/src/cluster_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ use crate::{
};
use std::time::Duration;

#[cfg(not(feature = "tls-rustls"))]
use crate::connection::TlsConnParams;

#[cfg(all(not(feature = "tokio-comp"), feature = "async-std-comp"))]
use crate::aio::{async_std::AsyncStd, RedisRuntime};
use arcstr::ArcStr;
Expand Down
12 changes: 6 additions & 6 deletions redis/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ implement_commands! {
}

/// Set the value and expiration of a key.
fn set_ex<K: ToRedisArgs, V: ToRedisArgs>(key: K, value: V, seconds: usize) {
fn set_ex<K: ToRedisArgs, V: ToRedisArgs>(key: K, value: V, seconds: u64) {
cmd("SETEX").arg(key).arg(seconds).arg(value)
}

/// Set the value and expiration in milliseconds of a key.
fn pset_ex<K: ToRedisArgs, V: ToRedisArgs>(key: K, value: V, milliseconds: usize) {
fn pset_ex<K: ToRedisArgs, V: ToRedisArgs>(key: K, value: V, milliseconds: u64) {
cmd("PSETEX").arg(key).arg(milliseconds).arg(value)
}

Expand Down Expand Up @@ -122,22 +122,22 @@ implement_commands! {
}

/// Set a key's time to live in seconds.
fn expire<K: ToRedisArgs>(key: K, seconds: usize) {
fn expire<K: ToRedisArgs>(key: K, seconds: i64) {
cmd("EXPIRE").arg(key).arg(seconds)
}

/// Set the expiration for a key as a UNIX timestamp.
fn expire_at<K: ToRedisArgs>(key: K, ts: usize) {
fn expire_at<K: ToRedisArgs>(key: K, ts: i64) {
cmd("EXPIREAT").arg(key).arg(ts)
}

/// Set a key's time to live in milliseconds.
fn pexpire<K: ToRedisArgs>(key: K, ms: usize) {
fn pexpire<K: ToRedisArgs>(key: K, ms: i64) {
cmd("PEXPIRE").arg(key).arg(ms)
}

/// Set the expiration for a key as a UNIX timestamp in milliseconds.
fn pexpire_at<K: ToRedisArgs>(key: K, ts: usize) {
fn pexpire_at<K: ToRedisArgs>(key: K, ts: i64) {
cmd("PEXPIREAT").arg(key).arg(ts)
}

Expand Down
3 changes: 2 additions & 1 deletion redis/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ pub(crate) fn create_rustls_config(
) -> RedisResult<rustls::ClientConfig> {
use crate::tls::ClientTlsParams;

#[allow(unused_mut)]
let mut root_store = RootCertStore::empty();
#[cfg(feature = "tls-rustls-webpki-roots")]
root_store.add_trust_anchors(TLS_SERVER_ROOTS.0.iter().map(|ta| {
Expand All @@ -804,8 +805,8 @@ pub(crate) fn create_rustls_config(
}));
#[cfg(all(
feature = "tls-rustls",
not(feature = "tls-rustls-webpki-roots"),
not(feature = "tls-native-tls"),
not(feature = "tls-rustls-webpki-roots")
))]
for cert in load_native_certs()? {
root_store.add(&rustls::Certificate(cert.0))?;
Expand Down
4 changes: 2 additions & 2 deletions redis/src/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ impl StreamId {
}

/// Does the message contain a particular field?
pub fn contains_key(&self, key: &&str) -> bool {
self.map.get(*key).is_some()
pub fn contains_key(&self, key: &str) -> bool {
self.map.get(key).is_some()
}

/// Returns how many field/value pairs exist in this message.
Expand Down
12 changes: 4 additions & 8 deletions redis/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,8 @@ impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue, S: BuildHasher + Default>
}

#[cfg(feature = "ahash")]
impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue, S: BuildHasher + Default> FromRedisValue
for ahash::AHashMap<K, V, S>
{
fn from_redis_value(v: &Value) -> RedisResult<ahash::AHashMap<K, V, S>> {
impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue> FromRedisValue for ahash::AHashMap<K, V> {
fn from_redis_value(v: &Value) -> RedisResult<ahash::AHashMap<K, V>> {
match *v {
Value::Nil => Ok(ahash::AHashMap::with_hasher(Default::default())),
_ => v
Expand Down Expand Up @@ -1423,10 +1421,8 @@ impl<T: FromRedisValue + Eq + Hash, S: BuildHasher + Default> FromRedisValue
}

#[cfg(feature = "ahash")]
impl<T: FromRedisValue + Eq + Hash, S: BuildHasher + Default> FromRedisValue
for ahash::AHashSet<T, S>
{
fn from_redis_value(v: &Value) -> RedisResult<ahash::AHashSet<T, S>> {
impl<T: FromRedisValue + Eq + Hash> FromRedisValue for ahash::AHashSet<T> {
fn from_redis_value(v: &Value) -> RedisResult<ahash::AHashSet<T>> {
let items = v
.as_sequence()
.ok_or_else(|| invalid_type_error_inner!(v, "Response type not hashset compatible"))?;
Expand Down
6 changes: 3 additions & 3 deletions redis/tests/test_streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ fn test_assorted_1() {
let _: RedisResult<String> = con.xadd_map("k3", "3000-0", map);

let reply: StreamRangeReply = con.xrange_all("k3").unwrap();
assert!(reply.ids[0].contains_key(&"ab"));
assert!(reply.ids[0].contains_key(&"ef"));
assert!(reply.ids[0].contains_key(&"ij"));
assert!(reply.ids[0].contains_key("ab"));
assert!(reply.ids[0].contains_key("ef"));
assert!(reply.ids[0].contains_key("ij"));

// test xadd w/ maxlength below...

Expand Down

0 comments on commit f9e8847

Please sign in to comment.