-
-
25 Dec 2019 15:42:02 UTC
- Distribution: Protocol-Redis
- Module version: 1.0011
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (0)
- Testers (1118 / 0 / 0)
- Kwalitee
Bus factor: 1- 94.89% Coverage
- License: perl_5
- Perl: v5.8.1
- Activity
24 month- Tools
- Download (6.26KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Test::More
- Reverse dependencies
- CPAN Testers List
- Dependency graph
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 support.
APIv1
Protocol::Redis APIv1 uses "Unified Request 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
Dan Book (Grinnz)
David Leadbeater (dgl)
Jan Henning Thorsen (jhthorsen)
Viacheslav Tykhanovskyi (vti)
Yaroslav Korshak (yko)
COPYRIGHT AND LICENSE
Copyright (C) 2011-2019, Sergey Zasenko.
This program is free software, you can redistribute it and/or modify it under the same terms as Perl 5.10.
Module Install Instructions
To install Protocol::Redis, copy and paste the appropriate command in to your terminal.
cpanm Protocol::Redis
perl -MCPAN -e shell install Protocol::Redis
For more information on module installation, please visit the detailed CPAN module installation guide.