Pipelining

Jedis.PipelineType
Pipeline([client::Client=get_global_client(); filter_multi_exec::Bool=false]) -> Pipeline

Creates a Pipeline client instance for executing commands in batch.

Fields

  • client::Client: Reference to the underlying Client connection.
  • resp::Vector{String}: Batched commands converted to RESP compliant string.
  • filter_multi_exec::Bool: Set true to filter out QUEUED responses in a MULTI/EXEC transaction.
  • multi_exec::Bool: Used to track and filter MULTI/EXEC transactions.
  • multi_exec_bitmask::Vector{Bool}: Used to track and filter MULTI/EXEC transactions.

Examples

julia> pipe = Pipeline();

julia> set("key", "value"; client=pipe);

julia> get("key"; client=pipe);

julia> execute(pipe)
2-element Array{String,1}:
 "OK"
 "value"
source
Jedis.add!Function
add!(pipe::Pipeline, command)

Add a RESP compliant command to a pipeline client.

source
Jedis.executeMethod
execute(command, pipe::Pipeline)

Add a RESP compliant command to a pipeline client, optionally filter out MULTI transaction responses before the EXEC call, e.g. "QUEUED".

Examples

julia> pipe = Pipeline();

julia> execute(["SET", "key", "value"]; client=pipe);

julia> execute(["GET", "key"]; client=pipe);

julia> execute(pipe)
2-element Array{String,1}:
 "OK"
 "value"
source
Jedis.executeMethod
execute(pipe::Pipeline[, batch_size::Int; filter_multi_exec=true])

Execute commands batched in a pipeline client, optionally filter out MULTI transaction responses before the EXEC call, e.g. "QUEUED". Set batch_size to batch commands with max commands per pipeline, defaults to use a single pipeline for all commands.

Examples

julia> pipe = Pipeline();

julia> set("key", "value"; client=pipe);

julia> get("key"; client=pipe);

julia> multi(; client=pipe);

julia> get("key"; client=pipe);

julia> get("key"; client=pipe);

julia> exec(; client=pipe);

julia> execute(pipe)
2-element Array{String,1}:
 "OK"
 "value"
 ["value", "value"]  # Only the response from final exec() call is returned
source
Base.pipelineFunction
pipeline(fn::Function[, batch_size::Int; clientt=get_global_client(), filter_multi_exec=false])

Execute commands batched in a pipeline client in a do block, optionally filter out MULTI transaction responses before the EXEC call, e.g. "QUEUED". Set batch_size to batch commands with max commands per pipeline, defaults to use a single pipeline for all commands.

Examples

julia> pipeline() do pipe
           lpush("example", 1, 2, 3, 4; client=pipe)
           lpop("example"; client=pipe)
           rpop("example"; client=pipe)
           multi_exec(; client=pipe) do
               lpop("example"; client=pipe)
               rpop("example"; client=pipe)
           end
           lpop("example"; client=pipe)
       end
5-element Array{Any,1}:
 4  # Integer response from lpush
 "4"  # String response from lpop
 "1"  # String response from rpop
 ["3", "2"]  # Array of String response from multi_exec do block, with responeses before the exec call filtered out
 nothing  # Nil response from final lpop
source