NAME
   Protocol::Redis - Redis protocol parser/encoder with asynchronous
   capabilities.

SYNOPSIS
       use Protocol::Redis;
       my $redis = Protocol::Redis->new;

       # Init used API version
       $redis->use_api(1) or die "API v1 not supported";

       $redis->parse("+foo\r\n");

       # get parsed message
       my $message = $redis->get_message;
       print "parsed message: ", $message->{data}, "\n";

       # asynchronous parsing interface
       $redis->on_message(sub {
           my ($redis, $message) = @_;
           print "parsed message: ", $message->{data}, "\n";
       });

       # parse pipelined message
       $redis->parse("+bar\r\n-error\r\n");

       # create message
       print "Get key message:\n",
         $redis->encode({type => '*', data => [
            {type => '$', data => 'string'},
            {type => '+', data => 'OK'}
       ]});

DESCRIPTION
   Redis protocol parser/encoder with asynchronous capabilities and
   pipelining <http://redis.io/topics/pipelining> support.

APIv1 (DRAFT)
   Protocol::Redis APIv1 uses "Unified Request Protocol
   <http://redis.io/topics/protocol>" for message encoding/parsing and
   supports methods described further. Client libraries should call
   $redis->use_api(1) to start using APIv1.

 "use_api"
       $redis->use_api(1) or die "API v1 not supported";

   Tell Protocol::Redis to use specific API version. Return false if API
   version not supported. Client libraries should call this method first
   and check returned value.

 "parse"
       $redis->parse("*2\r\n$4ping\r\n\r\n");

   Parse Redis protocol chunk.

 "get_message"
       while (my $message = $redis->get_message) {
           ...
       }

   Get parsed message or undef.

 "on_message"
       $redis->on_message(sub {
           my ($redis, $message) = @_;

       }

   Calls callback on each parsed message.

 "encode"
       my $string = $redis->encode({type => '+', data => 'test'});
       $string = $redis->encode(
           {type => '*', data => [
               {type => '$', data => 'test'}]});

   Encode data into redis message.

SUPPORT
 IRC
       #redis on irc.perl.org

DEVELOPMENT
 Repository
       http://github.com/und3f/protocol-redis

AUTHOR
   Sergey Zasenko, "[email protected]".

CREDITS
   David Leadbeater (dgl)

COPYRIGHT AND LICENSE
   Copyright (C) 2011, Sergey Zasenko.

   This program is free software, you can redistribute it and/or modify it
   under the same terms as Perl 5.10.