Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  REDISDB::PARSER (3)

.ds Aq ’


RedisDB::Parse::Redis - redis protocol parser for RedisDB



    use RedisDB::Parser;
    my $parser = RedisDB::Parser->new( master => $ref );


This module provides methods to build redis requests and parse replies from the server.



Creates new parser object. Following parameters may be specified:
<B>masterB> Arbitrary reference. It is passed to callbacks as the first argument. Normally it would be a reference to the object managing connection to redis-server. Reference is weakened.
<B>default_callbackB> Module allows you to set a separate callback for every new message. If there are no callbacks in queue, default_callback will be used.
<B>utf8B> If this parameter is set all data will be encoded as UTF-8 when building requests, and decoded from UTF-8 when parsing replies. By default module expects all data to be octet sequences.
<B>error_classB> If parsed message is an error message, parser will create object of the specified class with the message as the only constructor argument, and pass this object to the callback. By default RedisDB::Parser::Error class is used.


Returns name of the package that actually implements parser functionality. It may be either RedisDB::Parser::PP or RedisDB::Parser::XS.

CW$self->build_request($command, CW@arguments)

Encodes $command and @arguments as redis request.


Pushes callback to the queue of callbacks.


Set callback to invoke when there are no callbacks in queue.


Returns true if there are callbacks in queue


Invoke every callback from queue and the default callback with the given $reply. Can be used e.g. if connection to server has been lost to invoke every callback with error message.


Process new data received from the server. For every new reply method will invoke callback, either the one from the queue that was added using push_callback method, or default callback if the queue is empty. Callback passed two arguments: master value, and decoded reply from the server.


Here’s how the parser represents replies from redis-server:

    Status reply

Status replies are represented by string values without the initial plus sign and final end of the line symbols. I.e. +OK reply from the server will be parsed into OK string that will be passed to callback.

    Error reply

Error replies are represents as objects of error_class, which is by default RedisDB::Parser::Error. If parser detects error reply, it strips it off initial minus sign and final end of the line, and then passes result as sole argument to the new method of the error_class. This is the only case when parser produces blessed reference, and so callback may easily detect error condition by checking this.

    Integer reply

Parser represents integer reply as a scalar value

    Bulk reply

Parser represents bulk replies as scalar values. By default it treats result as a sequence of bytes, but if utf8 options is set it decodes result from UTF-8 and may croak if result is not a valid UTF-8 sequence. NULL bulk reply is represented as undefined value.

    Multi-bulk reply

Multi-bulk replies are returned as array references. Empty multi-bulk reply is represented as reference to empty array. Null multi-bulk reply is represented as undefined scalar.


Redis protocol specification: <>

Redis client library that uses this parser: RedisDB

Other Perl modules that parse redis protocol: Protocol::Redis, Protocol::Redis::XS, Redis::Parser::XS


Pavel Shaydo <zwon at>


Copyright 2011-2015 Pavel Shaydo.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 REDISDB::PARSER (3) 2015-02-09

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.