eredis_parser (eredis v2.6.2)

Link to this section Summary

Functions

Initialize the parser

Parses the (possibly partial) response from Redis. Returns either {ok, Value, NewState}, {ok, Value, Rest, NewState} or {continue, NewState}. External entry point for parsing.

Link to this section Types

Link to this type

continuation_data/0

Specs

continuation_data() :: any().
Link to this type

parser_state/0

Specs

parser_state() :: status_continue | bulk_continue | multibulk_continue.

Specs

pstate() :: #pstate{}.

Link to this section Functions

Initialize the parser
Link to this function

parse(State, Data)

Specs

parse(State :: pstate(), Data :: binary()) ->
         {ok, eredis:return_value(), NewState :: pstate()} |
         {ok, eredis:return_value(), Rest :: binary(), NewState :: pstate()} |
         {error, ErrString :: binary(), NewState :: pstate()} |
         {error, ErrString :: binary(), Rest :: binary(), NewState :: pstate()} |
         {continue, NewState :: pstate()} |
         {error, unknown_response}.

Parses the (possibly partial) response from Redis. Returns either {ok, Value, NewState}, {ok, Value, Rest, NewState} or {continue, NewState}. External entry point for parsing.

In case {ok, Value, NewState} is returned, Value contains the value returned by Redis. NewState will be an empty parser state.

In case {ok, Value, Rest, NewState} is returned, Value contains the most recent value returned by Redis, while Rest contains any extra data that was given, but was not part of the same response. In this case you should immeditely call parse again with Rest as the Data argument and NewState as the State argument.

In case {continue, NewState} is returned, more data is needed before a complete value can be returned. As soon as you have more data, call parse again with NewState as the State argument and any new binary data as the Data argument.

Parser in initial state, the data we receive will be the beginning of a response