Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update redis to 0.25. #306

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions redis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cluster = ["redis/cluster-async"]
deadpool = { path = "../", version = "0.10.0", default-features = false, features = [
"managed",
] }
redis = { version = "0.24", default-features = false, features = ["aio"] }
redis = { version = "0.25", default-features = false, features = ["aio"] }
serde = { package = "serde", version = "1.0", features = [
"derive",
], optional = true }
Expand All @@ -37,7 +37,7 @@ serde = { package = "serde", version = "1.0", features = [
config = { version = "0.13", features = ["json"] }
dotenvy = "0.15.0"
futures = "0.3.15"
redis = { version = "0.24", default-features = false, features = [
redis = { version = "0.25", default-features = false, features = [
"tokio-comp",
] }
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
32 changes: 16 additions & 16 deletions redis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::{

use deadpool::managed;
use redis::{
aio::{Connection as RedisConnection, ConnectionLike},
aio::{ConnectionLike, MultiplexedConnection},
Client, IntoConnectionInfo, RedisError, RedisResult,
};

Expand All @@ -46,11 +46,11 @@ deadpool::managed_reexports!("redis", Manager, Connection, RedisError, ConfigErr
/// Type alias for using [`deadpool::managed::RecycleResult`] with [`redis`].
type RecycleResult = managed::RecycleResult<RedisError>;

/// Wrapper around [`redis::aio::Connection`].
/// Wrapper around [`redis::aio::MultiplexedConnection`].
///
/// This structure implements [`redis::aio::ConnectionLike`] and can therefore
/// be used just like a regular [`redis::aio::Connection`].
#[allow(missing_debug_implementations)] // `redis::aio::Connection: !Debug`
/// be used just like a regular [`redis::aio::MultiplexedConnection`].
#[allow(missing_debug_implementations)] // `redis::aio::MultiplexedConnection: !Debug`
pub struct Connection {
conn: Object,
}
Expand All @@ -60,7 +60,7 @@ impl Connection {
///
/// This reduces the size of the [`Pool`].
#[must_use]
pub fn take(this: Self) -> RedisConnection {
pub fn take(this: Self) -> MultiplexedConnection {
Object::take(this.conn)
}
}
Expand All @@ -72,27 +72,27 @@ impl From<Object> for Connection {
}

impl Deref for Connection {
type Target = RedisConnection;
type Target = MultiplexedConnection;

fn deref(&self) -> &RedisConnection {
fn deref(&self) -> &MultiplexedConnection {
&self.conn
}
}

impl DerefMut for Connection {
fn deref_mut(&mut self) -> &mut RedisConnection {
fn deref_mut(&mut self) -> &mut MultiplexedConnection {
&mut self.conn
}
}

impl AsRef<redis::aio::Connection> for Connection {
fn as_ref(&self) -> &redis::aio::Connection {
impl AsRef<MultiplexedConnection> for Connection {
fn as_ref(&self) -> &MultiplexedConnection {
&self.conn
}
}

impl AsMut<redis::aio::Connection> for Connection {
fn as_mut(&mut self) -> &mut redis::aio::Connection {
impl AsMut<MultiplexedConnection> for Connection {
fn as_mut(&mut self) -> &mut MultiplexedConnection {
&mut self.conn
}
}
Expand Down Expand Up @@ -143,15 +143,15 @@ impl Manager {
}

impl managed::Manager for Manager {
type Type = RedisConnection;
type Type = MultiplexedConnection;
type Error = RedisError;

async fn create(&self) -> Result<RedisConnection, RedisError> {
let conn = self.client.get_async_connection().await?;
async fn create(&self) -> Result<MultiplexedConnection, RedisError> {
let conn = self.client.get_multiplexed_async_connection().await?;
Ok(conn)
}

async fn recycle(&self, conn: &mut RedisConnection, _: &Metrics) -> RecycleResult {
async fn recycle(&self, conn: &mut MultiplexedConnection, _: &Metrics) -> RecycleResult {
let ping_number = self.ping_number.fetch_add(1, Ordering::Relaxed).to_string();
// Using pipeline to avoid roundtrip for UNWATCH
let (n,) = redis::Pipeline::with_capacity(2)
Expand Down
Loading