Skip to content

Commit 6f9079c

Browse files
committed
examples: Update to redis 1
1 parent 8954d79 commit 6f9079c

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

Cargo.lock

Lines changed: 12 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tokio-redis/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ publish = false
66

77
[dependencies]
88
axum = { path = "../../axum" }
9-
bb8-redis = "0.24"
9+
bb8 = "0.9"
10+
redis = { version = "=1.0.0-rc.3", default-features = false, features = ["tokio-comp", "bb8"] }
1011
tokio = { version = "1.0", features = ["full"] }
1112
tracing = "0.1"
1213
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

examples/tokio-redis/src/main.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ use axum::{
1010
routing::get,
1111
Router,
1212
};
13-
use bb8_redis::{
14-
bb8::{self, Pool, PooledConnection},
15-
redis::AsyncCommands,
16-
RedisConnectionManager,
17-
};
13+
use redis::AsyncCommands;
1814
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
1915

2016
#[tokio::main]
@@ -28,8 +24,8 @@ async fn main() {
2824
.init();
2925

3026
tracing::debug!("connecting to redis");
31-
let manager = RedisConnectionManager::new("redis://localhost").unwrap();
32-
let pool = bb8::Pool::builder().build(manager).await.unwrap();
27+
let client = redis::Client::open("redis://localhost").unwrap();
28+
let pool = bb8::Pool::builder().build(client).await.unwrap();
3329

3430
{
3531
// ping the database before starting
@@ -56,7 +52,7 @@ async fn main() {
5652
axum::serve(listener, app).await.unwrap();
5753
}
5854

59-
type ConnectionPool = Pool<RedisConnectionManager>;
55+
type ConnectionPool = bb8::Pool<redis::Client>;
6056

6157
async fn using_connection_pool_extractor(
6258
State(pool): State<ConnectionPool>,
@@ -68,7 +64,7 @@ async fn using_connection_pool_extractor(
6864

6965
// we can also write a custom extractor that grabs a connection from the pool
7066
// which setup is appropriate depends on your application
71-
struct DatabaseConnection(PooledConnection<'static, RedisConnectionManager>);
67+
struct DatabaseConnection(bb8::PooledConnection<'static, redis::Client>);
7268

7369
impl<S> FromRequestParts<S> for DatabaseConnection
7470
where

0 commit comments

Comments
 (0)