Flux Redis v0.0.2 FluxRedis.PipelineManager View Source
Manage multiple commands for a single request.
Command modules
The functions of this module accepts a list/1 of tuple/0 with
command/0 and parser/0, both are automatically generated by the
following modules:
FluxRedis.HashManager.Commands- Commands to manage hashes and hash fields.
Pipeline Options
:as_transaction?- Iffalse, the request will not be handled as a transaction. Defaults tofalse. Acceptsboolean/0. For more information, please check transactions or pipeling? section fromRedixmodule.:no_reply?- Iftrue, the function returns:okafter successfully send the request to Redis. Defaults tofalse. Acceptsboolean/0.:timeout- Milliseconds to wait for a request sending. Defaults to5_000. Acceptsinteger/0or:infinity.
Link to this section Summary
Functions
Execute one or more commands in a single request.
Execute one or more commands in a single request.
Link to this section Types
Command specs generated by one of FluxRedis commands modules.
Parser function generated by one of the FluxRedis commands modules.
redix_data()
View Sourceredix_data() :: nil | String.t() | integer() | Redix.Error.t() | [redix_data()]
Result received after a Redix request.
Link to this section Functions
pipeline(pipeline_payload, opts \\ [])
View Source (since 0.0.2)pipeline([{command(), parser()}], keyword()) ::
:ok | {:ok, [any()]} | {:error, FluxRedis.Error.t()}
Execute one or more commands in a single request.
Returns :ok in case of successful request and no_reply? is set to true.
Returns {:ok, results} in case of successful request and :no_reply? is
set to false, where each result is defined according to the parser/0
or FluxRedis.Error.t/0 if the command failed to be processed.
Returns {:error, %FluxRedis.Error{}} if request failed to reach Redis.
Examples
iex> hash_storages = [
...> animals: [:phylum, :family],
...> cars: [:brand, :model],
...> users: :id
...> ]
...> Application.put_env(:flux_redis, :hash_storages, hash_storages)
...> animals = [
...> %{family: "Canidae", phylum: "Chordata"},
...> %{family: "Felidae", phylum: "Chordata"}
...> ]
...> car = %{brand: "Honda", model: "Civic", year: 2019}
...> users = [%{id: 1, name: "John"}, %{id: 2, name: "Doe"}]
...> pipeline_payload = [
...> FluxRedis.HashManager.Commands.set_many!(:animals, animals)
...> FluxRedis.HashManager.Commands.set!(:cars, car)
...> FluxRedis.HashManager.Commands.set_many!(:users, users)
...> FluxRedis.HashManager.Commands.delete(:users, 1)
...> FluxRedis.HashManager.Commands.count(:animals)
...> ]
...> FluxRedis.PipelineManager.pipeline(pipeline_payload)
{:ok, [2, :set, 2, :ok, 2]}
Execute one or more commands in a single request.
Similar to pipeline/2, but raises FluxRedis.Error.t/0 on failure (
either from a command or from the request itself).
Examples
iex> hash_storages = [
...> animals: [:phylum, :family],
...> cars: [:brand, :model],
...> users: :id
...> ]
...> Application.put_env(:flux_redis, :hash_storages, hash_storages)
...> animals = [
...> %{family: "Canidae", phylum: "Chordata"},
...> %{family: "Felidae", phylum: "Chordata"}
...> ]
...> car = %{brand: "Honda", model: "Civic", year: 2019}
...> users = [%{id: 1, name: "John"}, %{id: 2, name: "Doe"}]
...> pipeline_payload = [
...> FluxRedis.HashManager.Commands.set_many!(:animals, animals)
...> FluxRedis.HashManager.Commands.set!(:cars, car)
...> FluxRedis.HashManager.Commands.set_many!(:users, users)
...> FluxRedis.HashManager.Commands.delete(:users, 1)
...> FluxRedis.HashManager.Commands.count(:animals)
...> ]
...> FluxRedis.PipelineManager.pipeline!(pipeline_payload)
[2, :set, 2, :ok, 2]