Module eredis_parser

Data Types

continuation_data()

continuation_data() = any()

parser_state()

parser_state() = status_continue | bulk_continue | multibulk_continue

pstate()

pstate() = #pstate{state = parser_state() | undefined, continuation_data = continuation_data() | undefined}

Function Index

init/0Initialize the parser.
parse/2Parses the (possibly partial) response from Redis.

Function Details

init/0

init() -> any()

Initialize the parser

parse/2

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


Generated by EDoc