Replies: 1 comment 1 reply
-
Under the hood they're very similar, but For my use cases I usually set There's several ways to use the interfaces here, but the most flexible option involves setting let config = create_redis_config();
let pool = Builder::from_config(config)
.set_policy(ReconnectPolicy::new_exponential(0, 20, 30_000, 5))
.build_pool(13)?;
pool.prefer_connected(false);
// then use the `ClientLike` interfaces rather than directly calling `next()` or `next_connected()`.
let foo: Option<String> = pool.get("foo").await?;
// this is equivalent to
let foo: Option<String> = pool.next().get("foo").await?:
// if prefer_conneted is true
pool.prefer_connected(true);
// then the `ClientLike` interfaces call `next_connected()` under the hood
let foo: Option<String> = pool.get("foo").await?;
// is now equivalent to
let foo: Option<String> = pool.next_connected().get("foo").await?: |
Beta Was this translation helpful? Give feedback.
-
I'm migrating from deadpool_redis. There they have a
get
method to get a client from the pool. I see fred makes you decide whether you want just the next client or specifically the next connected client. Which should you use? If no client is connected will next_connected connect one? Similarly when building the client, should I set prefer_connected?Beta Was this translation helpful? Give feedback.
All reactions