Redix.Protocol.pack

You're seeing just the function pack, go back to Redix.Protocol module for more information.

Specs

pack([binary()]) :: iodata()

Packs a list of Elixir terms to a Redis (RESP) array.

This function returns an iodata (instead of a binary) because the packed result is usually sent to Redis through :gen_tcp.send/2 or similar. It can be converted to a binary with IO.iodata_to_binary/1.

All elements of elems are converted to strings with to_string/1, hence this function supports encoding everything that implements String.Chars.

Examples

iex> iodata = Redix.Protocol.pack(["SET", "mykey", 1])
iex> IO.iodata_to_binary(iodata)
"*3\r\n$3\r\nSET\r\n$5\r\nmykey\r\n$1\r\n1\r\n"