No description
This repository has been archived on 2026-08-22. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Dan Book 66fe5382d2 Optimize encode method
- Remove sub call overhead for each message and unroll recursion
2019-03-13 08:04:22 +08:00
lib/Protocol Optimize encode method 2019-03-13 08:04:22 +08:00
t prepared version 1.0 2011-05-05 13:20:34 +03:00
xt pod tests moved to xt 2011-03-21 23:01:58 +02:00
.gitignore use ExtUtils::MakeMaker for Makefile.PL 2017-05-03 08:56:11 +03:00
benchmark.pl benchmark fixup 2011-05-05 14:27:48 +03:00
Changes fixed typo 2017-05-03 12:51:04 +03:00
Makefile.PL Lower arbitrary perl requirement of Makefile.PL 2019-02-06 21:14:27 -05:00
MANIFEST.SKIP cleanup 2011-08-10 12:46:40 +03:00
README fixed typo 2017-05-03 12:51:04 +03:00

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

SYNOPSIS
        use Protocol::Redis;
        my $redis = Protocol::Redis->new(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
    Protocol::Redis APIv1 uses "Unified Request Protocol
    <http://redis.io/topics/protocol>" for message encoding/parsing and
    supports methods described further. Client libraries should specify API
    version during Protocol::Redis construction.

  "new"
        my $redis = Protocol::Redis->new(api => 1)
            or die "API v1 not supported";

    Construct Protocol::Redis object with specific API version support. If
    specified API version not supported constructor returns undef. Client
    libraries should always specify API version.

  "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.

  "api"
        my $api_version = $redis->api;

    Get API version.

SUPPORT
  IRC
        #redis on irc.perl.org

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

AUTHOR
    Sergey Zasenko, "undef@cpan.org".

CREDITS
    In alphabetical order

      David Leadbeater (dgl)

      Viacheslav Tykhanovskyi (vti)

      Yaroslav Korshak (yko)

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

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