Git Product home page Git Product logo

protocol-redis's Introduction

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

protocol-redis's People

Contributors

und3f avatar dgl avatar yko avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.