Skip to content

Commit 6c361a3

Browse files
Update redis to 0.26
Co-authored-by: hzlinyiyu <hzlinyiyu@corp.netease.com>
1 parent 7b933c5 commit 6c361a3

File tree

8 files changed

+51
-22
lines changed

8 files changed

+51
-22
lines changed

redis/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
- Update `redis` dependency to version `0.26`
13+
1214
## [0.15.1] - 2024-05-04
1315

1416
- Update `deadpool` dependency to version `0.12`
@@ -183,4 +185,4 @@ Release of 0.6 and 0.7 with the following feature backported:
183185
[0.4.1]: https://github.com/bikeshedder/deadpool/compare/deadpool-redis-v0.4.0...deadpool-redis-v0.4.1
184186
[0.4.0]: https://github.com/bikeshedder/deadpool/compare/deadpool-redis-v0.3.0...deadpool-redis-v0.4.0
185187
[0.3.0]: https://github.com/bikeshedder/deadpool/compare/deadpool-redis-v0.2.0...deadpool-redis-v0.3.0
186-
[0.2.0]: https://github.com/bikeshedder/deadpool/releases/tag/deadpool-redis-v0.2.0
188+
[0.2.0]: https://github.com/bikeshedder/deadpool/releases/tag/deadpool-redis-v0.2.0

redis/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cluster = ["redis/cluster-async"]
2828
deadpool = { path = "../", version = "0.12.0", default-features = false, features = [
2929
"managed",
3030
] }
31-
redis = { version = "0.25", default-features = false, features = ["aio"] }
31+
redis = { version = "0.26", default-features = false, features = ["aio"] }
3232
serde = { package = "serde", version = "1.0", features = [
3333
"derive",
3434
], optional = true }
@@ -37,7 +37,7 @@ serde = { package = "serde", version = "1.0", features = [
3737
config = { version = "0.14", features = ["json"] }
3838
dotenvy = "0.15.0"
3939
futures = "0.3.15"
40-
redis = { version = "0.25", default-features = false, features = [
40+
redis = { version = "0.26", default-features = false, features = [
4141
"tokio-comp",
4242
] }
4343
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }

redis/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async fn main() {
3030
let mut conn = pool.get().await.unwrap();
3131
cmd("SET")
3232
.arg(&["deadpool/test_key", "42"])
33-
.query_async::<_, ()>(&mut conn)
33+
.query_async::<()>(&mut conn)
3434
.await.unwrap();
3535
}
3636
{
@@ -74,7 +74,7 @@ async fn main() {
7474
let mut conn = pool.get().await.unwrap();
7575
cmd("SET")
7676
.arg(&["deadpool/test_key", "42"])
77-
.query_async::<_, ()>(&mut conn)
77+
.query_async::<()>(&mut conn)
7878
.await.unwrap();
7979
}
8080
{
@@ -108,7 +108,7 @@ async fn main() {
108108
let mut conn = pool.get().await.unwrap();
109109
cmd("SET")
110110
.arg(&["deadpool/test_key", "42"])
111-
.query_async::<_, ()>(&mut conn)
111+
.query_async::<()>(&mut conn)
112112
.await.unwrap();
113113
}
114114
{
@@ -158,7 +158,7 @@ async fn main() {
158158
let mut conn = pool.get().await.unwrap();
159159
cmd("SET")
160160
.arg(&["deadpool/test_key", "42"])
161-
.query_async::<_, ()>(&mut conn)
161+
.query_async::<()>(&mut conn)
162162
.await.unwrap();
163163
}
164164
{

redis/src/cluster/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl managed::Manager for Manager {
144144
let ping_number = self.ping_number.fetch_add(1, Ordering::Relaxed).to_string();
145145
let n = redis::cmd("PING")
146146
.arg(&ping_number)
147-
.query_async::<_, String>(conn)
147+
.query_async::<String>(conn)
148148
.await?;
149149
if n == ping_number {
150150
Ok(())

redis/src/config.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,24 +251,51 @@ pub struct RedisConnectionInfo {
251251

252252
/// Optionally a password that should be used for connection.
253253
pub password: Option<String>,
254+
255+
/// Version of the protocol to use.
256+
pub protocol: ProtocolVersion,
257+
}
258+
259+
/// This is a 1:1 copy of the [`redis::ProtocolVersion`] struct.
260+
/// Enum representing the communication protocol with the server. This enum represents the types
261+
/// of data that the server can send to the client, and the capabilities that the client can use.
262+
#[derive(Clone, Eq, PartialEq, Default, Debug, Copy)]
263+
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
264+
#[cfg_attr(feature = "serde", serde(crate = "serde"))]
265+
pub enum ProtocolVersion {
266+
/// <https://github.com/redis/redis-specifications/blob/master/protocol/RESP2.md>
267+
#[default]
268+
RESP2,
269+
/// <https://github.com/redis/redis-specifications/blob/master/protocol/RESP3.md>
270+
RESP3,
254271
}
255272

256273
impl From<RedisConnectionInfo> for redis::RedisConnectionInfo {
257274
fn from(info: RedisConnectionInfo) -> Self {
275+
let protocol = match info.protocol {
276+
ProtocolVersion::RESP2 => redis::ProtocolVersion::RESP2,
277+
ProtocolVersion::RESP3 => redis::ProtocolVersion::RESP3,
278+
};
258279
Self {
259280
db: info.db,
260281
username: info.username,
261282
password: info.password,
283+
protocol,
262284
}
263285
}
264286
}
265287

266288
impl From<redis::RedisConnectionInfo> for RedisConnectionInfo {
267289
fn from(info: redis::RedisConnectionInfo) -> Self {
290+
let protocol = match info.protocol {
291+
redis::ProtocolVersion::RESP2 => ProtocolVersion::RESP2,
292+
redis::ProtocolVersion::RESP3 => ProtocolVersion::RESP3,
293+
};
268294
Self {
269295
db: info.db,
270296
username: info.username,
271297
password: info.password,
298+
protocol,
272299
}
273300
}
274301
}

redis/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl managed::Manager for Manager {
159159
.ignore()
160160
.cmd("PING")
161161
.arg(&ping_number)
162-
.query_async::<_, (String,)>(conn)
162+
.query_async::<(String,)>(conn)
163163
.await?;
164164
if n == ping_number {
165165
Ok(())

redis/tests/redis.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async fn test_aborted_command() {
7171
// https://github.com/mitsuhiko/redis-rs/issues/489
7272
cmd("PING")
7373
.arg("wrong")
74-
.query_async::<_, String>(&mut conn)
74+
.query_async::<String>(&mut conn)
7575
.now_or_never();
7676
}
7777
{
@@ -94,7 +94,7 @@ async fn test_recycled() {
9494

9595
cmd("CLIENT")
9696
.arg("ID")
97-
.query_async::<_, i64>(&mut conn)
97+
.query_async::<i64>(&mut conn)
9898
.await
9999
.unwrap()
100100
};
@@ -104,7 +104,7 @@ async fn test_recycled() {
104104

105105
let new_client_id = cmd("CLIENT")
106106
.arg("ID")
107-
.query_async::<_, i64>(&mut conn)
107+
.query_async::<i64>(&mut conn)
108108
.await
109109
.unwrap();
110110

@@ -130,13 +130,13 @@ async fn test_recycled_with_watch() {
130130

131131
let client_id = cmd("CLIENT")
132132
.arg("ID")
133-
.query_async::<_, i64>(&mut conn)
133+
.query_async::<i64>(&mut conn)
134134
.await
135135
.unwrap();
136136

137137
cmd("WATCH")
138138
.arg(WATCHED_KEY)
139-
.query_async::<_, ()>(&mut conn)
139+
.query_async::<()>(&mut conn)
140140
.await
141141
.unwrap();
142142

@@ -148,7 +148,7 @@ async fn test_recycled_with_watch() {
148148

149149
let new_client_id = cmd("CLIENT")
150150
.arg("ID")
151-
.query_async::<_, i64>(&mut txn_conn)
151+
.query_async::<i64>(&mut txn_conn)
152152
.await
153153
.unwrap();
154154

@@ -161,7 +161,7 @@ async fn test_recycled_with_watch() {
161161
// Start transaction on another key
162162
cmd("WATCH")
163163
.arg(TXN_KEY)
164-
.query_async::<_, ()>(&mut txn_conn)
164+
.query_async::<()>(&mut txn_conn)
165165
.await
166166
.unwrap();
167167

@@ -172,7 +172,7 @@ async fn test_recycled_with_watch() {
172172
cmd("SET")
173173
.arg(WATCHED_KEY)
174174
.arg("v")
175-
.query_async::<_, ()>(&mut writer_conn)
175+
.query_async::<()>(&mut writer_conn)
176176
.await
177177
.unwrap();
178178
}
@@ -181,12 +181,12 @@ async fn test_recycled_with_watch() {
181181
let txn_result = pipe()
182182
.atomic()
183183
.set(TXN_KEY, "foo")
184-
.query_async::<_, Value>(&mut txn_conn)
184+
.query_async::<Value>(&mut txn_conn)
185185
.await
186186
.unwrap();
187187
assert_eq!(
188188
txn_result,
189-
Value::Bulk(vec![Value::Okay]),
189+
Value::Array(vec![Value::Okay]),
190190
"redis transaction in recycled connection aborted",
191191
);
192192
}

redis/tests/redis_cluster.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ async fn test_aborted_command() {
7676
// https://github.com/mitsuhiko/redis-rs/issues/489
7777
cmd("PING")
7878
.arg("wrong")
79-
.query_async::<_, String>(&mut conn)
79+
.query_async::<String>(&mut conn)
8080
.now_or_never();
8181
}
8282
{
@@ -99,7 +99,7 @@ async fn test_recycled() {
9999

100100
cmd("CLIENT")
101101
.arg("ID")
102-
.query_async::<_, i64>(&mut conn)
102+
.query_async::<i64>(&mut conn)
103103
.await
104104
.unwrap()
105105
};
@@ -109,7 +109,7 @@ async fn test_recycled() {
109109

110110
let new_client_id = cmd("CLIENT")
111111
.arg("ID")
112-
.query_async::<_, i64>(&mut conn)
112+
.query_async::<i64>(&mut conn)
113113
.await
114114
.unwrap();
115115

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy