Vdr.RedisStream.CommandParser (veidrodelis v0.1.8)

Copy Markdown View Source

This is an internal module for parsing Redis commands into command tuples.

Parses Redis replication stream commands into command tuples.

Summary

Functions

Parse a Redis command represented as a list of binary arguments into a command tuple.

Functions

parse(args)

@spec parse([binary()]) :: {:ok, tuple(), [binary()]}

Parse a Redis command represented as a list of binary arguments into a command tuple.

Returns {:ok, command_tuple, affected_keys} for all commands. Unknown commands return a generic tuple.

Examples

iex> parse(["SET", "key", "value"])
{:ok, {:set, "key", "value"}, ["key"]}

iex> parse(["SADD", "myset", "m1", "m2"])
{:ok, {:sadd, "myset", ["m1", "m2"]}, ["myset"]}

iex> parse(["UNKNOWN", "arg"])
{:ok, {:generic, ["UNKNOWN", "arg"]}, []}