diff --git a/Project.toml b/Project.toml index c994472..d2ba45f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Jedis" uuid = "b89ccfe0-2c5f-46f6-b89b-da3e1c2e286f" authors = ["Jack Chan "] -version = "0.2.14" +version = "0.2.15" [deps] MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d" diff --git a/src/execute.jl b/src/execute.jl index 91afeaf..da1498f 100644 --- a/src/execute.jl +++ b/src/execute.jl @@ -143,12 +143,12 @@ function execute(pipe::Pipeline, batch_size::Int) n_cmd = length(pipe.resp) messages = Vector{Any}(undef, n_cmd) - l, r = 1, min(batch_size, n_cmd) + l, r = 1, batch_size while l <= n_cmd - write(pipe.client.socket, join(pipe.resp[l:r])) + write(pipe.client.socket, join(pipe.resp[l:min(r, n_cmd)])) - for i in l:r + for i in l:min(r, n_cmd) messages[i] = recv(pipe.client.socket) end diff --git a/test/test_pipeline.jl b/test/test_pipeline.jl index c297477..78a12b9 100644 --- a/test/test_pipeline.jl +++ b/test/test_pipeline.jl @@ -46,8 +46,16 @@ end end @testset "Pipeline - Batching" begin - batch_size = 100 - result = pipeline(100) do pipe + batch_size = 333 + result = pipeline(batch_size) do pipe + for _ in 1:1000 + lrange("nothing", 0, -1; client=pipe) + end + end + @test result == fill([], 1000) + + batch_size = 3333 + result = pipeline(batch_size) do pipe for _ in 1:1000 lrange("nothing", 0, -1; client=pipe) end