Skip to content

Commit

Permalink
Revert "Make get return Bytes instead of Vec<u8>"
Browse files Browse the repository at this point in the history
This reverts commit e3521cd.
  • Loading branch information
Bajix committed Mar 24, 2024
1 parent 91fc32f commit c78b18f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion crates/redis-swapplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ rust-version = "1.75"

[dependencies]
arc-swap = "1.7"
bytes = "1.5.0"
derive-redis-swapplex = { version = "0.11.0", path = "../derive-redis-swapplex" }
env-url = "2"
futures-util = "0.3"
Expand Down
9 changes: 4 additions & 5 deletions crates/redis-swapplex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ extern crate self as redis_swapplex;

mod bytes;

pub use crate::bytes::IntoBytes;
pub use ::bytes::Bytes;
pub use bytes::IntoBytes;

use arc_swap::{ArcSwapAny, ArcSwapOption, Cache};
pub use derive_redis_swapplex::ConnectionManagerContext;
Expand Down Expand Up @@ -523,13 +522,13 @@ where
}

/// Get the value of a key using auto-batched MGET commands
pub async fn get<K: IntoBytes>(key: K) -> Result<Option<Bytes>, ErrorKind> {
pub async fn get<K: IntoBytes>(key: K) -> Result<Option<Vec<u8>>, ErrorKind> {
struct MGetQueue;

#[local_queue(buffer_size = 2048)]
impl TaskQueue for MGetQueue {
type Task = Vec<u8>;
type Value = Result<Option<Bytes>, ErrorKind>;
type Value = Result<Option<Vec<u8>>, ErrorKind>;

async fn batch_process<const N: usize>(
batch: PendingAssignment<'_, Self, N>,
Expand All @@ -538,7 +537,7 @@ pub async fn get<K: IntoBytes>(key: K) -> Result<Option<Bytes>, ErrorKind> {
let assignment = batch.into_assignment();
let (front, back) = assignment.as_slices();

let data: Result<Vec<Option<Bytes>>, RedisError> = redis::cmd("MGET")
let data: Result<Vec<Option<Vec<u8>>>, RedisError> = redis::cmd("MGET")
.arg(front)
.arg(back)
.query_async(&mut conn)
Expand Down

0 comments on commit c78b18f

Please sign in to comment.