Browse files

Release v1.961 (based on fa30bc6)

  • Loading branch information...
1 parent a8f1214 commit b226caf0a9abb42eb530934fb60cda9951ffbca7 @melo melo committed Jan 23, 2013
Showing with 141 additions and 62 deletions.
  1. +3 −0 Changes
  2. +4 −4 META.json
  3. +4 −4 META.yml
  4. +4 −4 MYMETA.json
  5. +4 −4 MYMETA.yml
  6. +7 −7 Makefile
  7. +1 −1 Makefile.PL
  8. +1 −1 README
  9. +29 −10 blib/lib/Redis.pm
  10. +2 −2 blib/lib/Redis/Hash.pm
  11. +2 −2 blib/lib/Redis/List.pm
  12. +15 −5 blib/man3/Redis.3
  13. +1 −1 blib/man3/Redis::Hash.3
  14. +1 −1 blib/man3/Redis::List.3
  15. +29 −10 lib/Redis.pm
  16. +2 −2 lib/Redis/Hash.pm
  17. +2 −2 lib/Redis/List.pm
  18. +30 −2 t/04-pipeline.t
View
3 Changes
@@ -1,5 +1,8 @@
Revision history for Redis
+1.961 2013-01-23T15:09:47Z
+ * Add wait_one_response() for better pipeline management
+
1.960 2013-01-23T11:28:40Z
* Make the new() name parameter safe to use with all redis-
server versions
View
8 META.json
@@ -59,15 +59,15 @@
"provides" : {
"Redis" : {
"file" : "lib/Redis.pm",
- "version" : "1.960"
+ "version" : "1.961"
},
"Redis::Hash" : {
"file" : "lib/Redis/Hash.pm",
- "version" : "1.960"
+ "version" : "1.961"
},
"Redis::List" : {
"file" : "lib/Redis/List.pm",
- "version" : "1.960"
+ "version" : "1.961"
}
},
"release_status" : "stable",
@@ -82,7 +82,7 @@
"web" : "https://github.com/melo/perl-redis"
}
},
- "version" : "1.960",
+ "version" : "1.961",
"x_Dist_Zilla" : {
"perl" : {
"version" : "5.014002"
View
8 META.yml
@@ -32,21 +32,21 @@ no_index:
provides:
Redis:
file: lib/Redis.pm
- version: 1.960
+ version: 1.961
Redis::Hash:
file: lib/Redis/Hash.pm
- version: 1.960
+ version: 1.961
Redis::List:
file: lib/Redis/List.pm
- version: 1.960
+ version: 1.961
requires:
Try::Tiny: 0
perl: v5.8.8
resources:
bugtracker: https://github.com/melo/perl-redis/issues
homepage: http://metacpan.org/release/Redis/
repository: git://github.com/melo/perl-redis.git
-version: 1.960
+version: 1.961
x_Dist_Zilla:
perl:
version: 5.014002
View
8 MYMETA.json
@@ -68,15 +68,15 @@
"provides" : {
"Redis" : {
"file" : "lib/Redis.pm",
- "version" : "1.960"
+ "version" : "1.961"
},
"Redis::Hash" : {
"file" : "lib/Redis/Hash.pm",
- "version" : "1.960"
+ "version" : "1.961"
},
"Redis::List" : {
"file" : "lib/Redis/List.pm",
- "version" : "1.960"
+ "version" : "1.961"
}
},
"release_status" : "stable",
@@ -91,7 +91,7 @@
"web" : "https://github.com/melo/perl-redis"
}
},
- "version" : "1.960",
+ "version" : "1.961",
"x_Dist_Zilla" : {
"perl" : {
"version" : "5.014002"
View
8 MYMETA.yml
@@ -32,20 +32,20 @@ no_index:
provides:
Redis:
file: lib/Redis.pm
- version: 1.960
+ version: 1.961
Redis::Hash:
file: lib/Redis/Hash.pm
- version: 1.960
+ version: 1.961
Redis::List:
file: lib/Redis/List.pm
- version: 1.960
+ version: 1.961
requires:
Try::Tiny: 0
resources:
bugtracker: https://github.com/melo/perl-redis/issues
homepage: http://metacpan.org/release/Redis/
repository: git://github.com/melo/perl-redis.git
-version: 1.960
+version: 1.961
x_Dist_Zilla:
perl:
version: 5.014002
View
14 Makefile
@@ -21,7 +21,7 @@
# NAME => q[Redis]
# PREREQ_PM => { Test::More=>q[0.98], Try::Tiny=>q[0], IO::String=>q[0], Digest::SHA=>q[0], Test::Fatal=>q[0], IPC::Cmd=>q[0], Test::Deep=>q[0] }
# TEST_REQUIRES => { }
-# VERSION => q[1.960]
+# VERSION => q[1.961]
# test => { TESTS=>q[t/*.t] }
# --- MakeMaker post_initialize section:
@@ -61,11 +61,11 @@ DIRFILESEP = /
DFSEP = $(DIRFILESEP)
NAME = Redis
NAME_SYM = Redis
-VERSION = 1.960
+VERSION = 1.961
VERSION_MACRO = VERSION
-VERSION_SYM = 1_960
+VERSION_SYM = 1_961
DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\"
-XS_VERSION = 1.960
+XS_VERSION = 1.961
XS_VERSION_MACRO = XS_VERSION
XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"
INST_ARCHLIB = blib/arch
@@ -267,7 +267,7 @@ RCS_LABEL = rcs -Nv$(VERSION_SYM): -q
DIST_CP = best
DIST_DEFAULT = tardist
DISTNAME = Redis
-DISTVNAME = Redis-1.960
+DISTVNAME = Redis-1.961
# --- MakeMaker macro section:
@@ -516,7 +516,7 @@ metafile : create_distdir
$(NOECHO) $(ECHO) ' - inc' >> META_new.yml
$(NOECHO) $(ECHO) 'requires:' >> META_new.yml
$(NOECHO) $(ECHO) ' Try::Tiny: 0' >> META_new.yml
- $(NOECHO) $(ECHO) 'version: 1.960' >> META_new.yml
+ $(NOECHO) $(ECHO) 'version: 1.961' >> META_new.yml
-$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
$(NOECHO) $(ECHO) Generating META.json
$(NOECHO) $(ECHO) '{' > META_new.json
@@ -561,7 +561,7 @@ metafile : create_distdir
$(NOECHO) $(ECHO) ' }' >> META_new.json
$(NOECHO) $(ECHO) ' },' >> META_new.json
$(NOECHO) $(ECHO) ' "release_status" : "stable",' >> META_new.json
- $(NOECHO) $(ECHO) ' "version" : "1.960"' >> META_new.json
+ $(NOECHO) $(ECHO) ' "version" : "1.961"' >> META_new.json
$(NOECHO) $(ECHO) '}' >> META_new.json
-$(NOECHO) $(MV) META_new.json $(DISTVNAME)/META.json
View
2 Makefile.PL
@@ -27,7 +27,7 @@ my %WriteMakefileArgs = (
"PREREQ_PM" => {
"Try::Tiny" => 0
},
- "VERSION" => "1.960",
+ "VERSION" => "1.961",
"test" => {
"TESTS" => "t/*.t"
}
View
2 README
@@ -1,7 +1,7 @@
This archive contains the distribution Redis,
-version 1.960:
+version 1.961:
Perl binding for Redis database
View
39 blib/lib/Redis.pm
@@ -1,7 +1,7 @@
package Redis;
# ABSTRACT: Perl binding for Redis database
-our $VERSION = '1.960'; # VERSION
+our $VERSION = '1.961'; # VERSION
our $AUTHORITY = 'cpan:MELO'; # AUTHORITY
use warnings;
@@ -179,10 +179,20 @@ sub __run_cmd {
sub wait_all_responses {
my ($self) = @_;
- for my $handler (splice @{ $self->{queue} }) {
- my ($command, $cb, $collect_errors) = @$handler;
- $cb->($self->__read_response($command, $collect_errors));
- }
+ my $queue = $self->{queue};
+ $self->wait_one_response while @$queue;
+
+ return;
+}
+
+sub wait_one_response {
+ my ($self) = @_;
+
+ my $handler = shift @{ $self->{queue} };
+ return unless $handler;
+
+ my ($command, $cb, $collect_errors) = @$handler;
+ $cb->($self->__read_response($command, $collect_errors));
return;
}
@@ -719,7 +729,7 @@ Redis - Perl binding for Redis database
=head1 VERSION
-version 1.960
+version 1.961
=head1 SYNOPSIS
@@ -762,6 +772,8 @@ version 1.960
});
long_computation();
$redis->wait_all_responses;
+ ## or
+ $redis->wait_one_response();
## Or run a large batch of commands in a pipeline
my %hash = _get_large_batch_of_commands();
@@ -823,23 +835,25 @@ soon as at least one of the following conditions holds:
=item *
-A non-pipelined (synchronous) command has been sent on the same connection
+A non-pipelined (synchronous) command is called on the same connection
=item *
A pub/sub subscription command (one of C<subscribe>, C<unsubscribe>,
-C<psubscribe>, or C<punsubscribe>) is about to be sent on the same connection.
+C<psubscribe>, or C<punsubscribe>) is about to be called on the same
+connection.
=item *
-The L</wait_all_responses> method is called explicitly.
+One of L</wait_all_responses> or L</wait_one_response> methods is called
+explicitly.
=back
The coderef you supply to a pipelined command method is invoked once the
response is available. It takes two arguments, C<$reply> and C<$error>. If
C<$error> is defined, it contains the text of an error reply sent by the Redis
-server. Otherwise, C<$reply> is the non-error reply. For almost all commands,
+server. Otherwise, C<$reply> is the non-error reply. For almost all commands,
that means it's C<undef>, or a defined but non-reference scalar, or an array
ref of any of those; but see L</keys>, L</info>, and L</exec>.
@@ -1001,6 +1015,11 @@ connection name string. The most important one: no spaces.
Waits until all pending pipelined responses have been received, and invokes the
pipeline callback for each one. See L</PIPELINING>.
+=head3 wait_one_response
+
+Waits until the first pending pipelined response has been received, and invokes
+its callback. See L</PIPELINING>.
+
=head2 Transaction-handling commands
B<Warning:> the behaviour of these commands when combined with pipelining is
View
4 blib/lib/Redis/Hash.pm
@@ -1,7 +1,7 @@
package Redis::Hash;
# ABSTRACT: tie Perl hashes to Redis hashes
-our $VERSION = '1.960'; # VERSION
+our $VERSION = '1.961'; # VERSION
our $AUTHORITY = 'cpan:MELO'; # AUTHORITY
use strict;
@@ -79,7 +79,7 @@ Redis::Hash - tie Perl hashes to Redis hashes
=head1 VERSION
-version 1.960
+version 1.961
=head1 DESCRIPTION
View
4 blib/lib/Redis/List.pm
@@ -1,7 +1,7 @@
package Redis::List;
# ABSTRACT: tie Perl arrays to Redis lists
-our $VERSION = '1.960'; # VERSION
+our $VERSION = '1.961'; # VERSION
our $AUTHORITY = 'cpan:MELO'; # AUTHORITY
use strict;
@@ -99,7 +99,7 @@ Redis::List - tie Perl arrays to Redis lists
=head1 VERSION
-version 1.960
+version 1.961
=head1 SYNOPSYS
View
20 blib/man3/Redis.3
@@ -142,7 +142,7 @@
Redis \- Perl binding for Redis database
.SH "VERSION"
.IX Header "VERSION"
-version 1.960
+version 1.961
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
@@ -185,6 +185,8 @@ version 1.960
\& });
\& long_computation();
\& $redis\->wait_all_responses;
+\& ## or
+\& $redis\->wait_one_response();
\&
\& ## Or run a large batch of commands in a pipeline
\& my %hash = _get_large_batch_of_commands();
@@ -243,17 +245,19 @@ method call:
Pending responses to pipelined commands are processed in a single batch, as
soon as at least one of the following conditions holds:
.IP "\(bu" 4
-A non-pipelined (synchronous) command has been sent on the same connection
+A non-pipelined (synchronous) command is called on the same connection
.IP "\(bu" 4
A pub/sub subscription command (one of \f(CW\*(C`subscribe\*(C'\fR, \f(CW\*(C`unsubscribe\*(C'\fR,
-\&\f(CW\*(C`psubscribe\*(C'\fR, or \f(CW\*(C`punsubscribe\*(C'\fR) is about to be sent on the same connection.
+\&\f(CW\*(C`psubscribe\*(C'\fR, or \f(CW\*(C`punsubscribe\*(C'\fR) is about to be called on the same
+connection.
.IP "\(bu" 4
-The \*(L"wait_all_responses\*(R" method is called explicitly.
+One of \*(L"wait_all_responses\*(R" or \*(L"wait_one_response\*(R" methods is called
+explicitly.
.PP
The coderef you supply to a pipelined command method is invoked once the
response is available. It takes two arguments, \f(CW$reply\fR and \f(CW$error\fR. If
\&\f(CW$error\fR is defined, it contains the text of an error reply sent by the Redis
-server. Otherwise, \f(CW$reply\fR is the non-error reply. For almost all commands,
+server. Otherwise, \f(CW$reply\fR is the non-error reply. For almost all commands,
that means it's \f(CW\*(C`undef\*(C'\fR, or a defined but non-reference scalar, or an array
ref of any of those; but see \*(L"keys\*(R", \*(L"info\*(R", and \*(L"exec\*(R".
.PP
@@ -416,6 +420,12 @@ connection name string. The most important one: no spaces.
.PP
Waits until all pending pipelined responses have been received, and invokes the
pipeline callback for each one. See \*(L"\s-1PIPELINING\*(R"\s0.
+.PP
+\fIwait_one_response\fR
+.IX Subsection "wait_one_response"
+.PP
+Waits until the first pending pipelined response has been received, and invokes
+its callback. See \*(L"\s-1PIPELINING\*(R"\s0.
.SS "Transaction-handling commands"
.IX Subsection "Transaction-handling commands"
\&\fBWarning:\fR the behaviour of these commands when combined with pipelining is
View
2 blib/man3/Redis::Hash.3
@@ -142,7 +142,7 @@
Redis::Hash \- tie Perl hashes to Redis hashes
.SH "VERSION"
.IX Header "VERSION"
-version 1.960
+version 1.961
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Ties a Perl hash to Redis. Note that it doesn't use Redis Hashes, but
View
2 blib/man3/Redis::List.3
@@ -142,7 +142,7 @@
Redis::List \- tie Perl arrays to Redis lists
.SH "VERSION"
.IX Header "VERSION"
-version 1.960
+version 1.961
.SH "SYNOPSYS"
.IX Header "SYNOPSYS"
.Vb 1
View
39 lib/Redis.pm
@@ -1,7 +1,7 @@
package Redis;
# ABSTRACT: Perl binding for Redis database
-our $VERSION = '1.960'; # VERSION
+our $VERSION = '1.961'; # VERSION
our $AUTHORITY = 'cpan:MELO'; # AUTHORITY
use warnings;
@@ -179,10 +179,20 @@ sub __run_cmd {
sub wait_all_responses {
my ($self) = @_;
- for my $handler (splice @{ $self->{queue} }) {
- my ($command, $cb, $collect_errors) = @$handler;
- $cb->($self->__read_response($command, $collect_errors));
- }
+ my $queue = $self->{queue};
+ $self->wait_one_response while @$queue;
+
+ return;
+}
+
+sub wait_one_response {
+ my ($self) = @_;
+
+ my $handler = shift @{ $self->{queue} };
+ return unless $handler;
+
+ my ($command, $cb, $collect_errors) = @$handler;
+ $cb->($self->__read_response($command, $collect_errors));
return;
}
@@ -719,7 +729,7 @@ Redis - Perl binding for Redis database
=head1 VERSION
-version 1.960
+version 1.961
=head1 SYNOPSIS
@@ -762,6 +772,8 @@ version 1.960
});
long_computation();
$redis->wait_all_responses;
+ ## or
+ $redis->wait_one_response();
## Or run a large batch of commands in a pipeline
my %hash = _get_large_batch_of_commands();
@@ -823,23 +835,25 @@ soon as at least one of the following conditions holds:
=item *
-A non-pipelined (synchronous) command has been sent on the same connection
+A non-pipelined (synchronous) command is called on the same connection
=item *
A pub/sub subscription command (one of C<subscribe>, C<unsubscribe>,
-C<psubscribe>, or C<punsubscribe>) is about to be sent on the same connection.
+C<psubscribe>, or C<punsubscribe>) is about to be called on the same
+connection.
=item *
-The L</wait_all_responses> method is called explicitly.
+One of L</wait_all_responses> or L</wait_one_response> methods is called
+explicitly.
=back
The coderef you supply to a pipelined command method is invoked once the
response is available. It takes two arguments, C<$reply> and C<$error>. If
C<$error> is defined, it contains the text of an error reply sent by the Redis
-server. Otherwise, C<$reply> is the non-error reply. For almost all commands,
+server. Otherwise, C<$reply> is the non-error reply. For almost all commands,
that means it's C<undef>, or a defined but non-reference scalar, or an array
ref of any of those; but see L</keys>, L</info>, and L</exec>.
@@ -1001,6 +1015,11 @@ connection name string. The most important one: no spaces.
Waits until all pending pipelined responses have been received, and invokes the
pipeline callback for each one. See L</PIPELINING>.
+=head3 wait_one_response
+
+Waits until the first pending pipelined response has been received, and invokes
+its callback. See L</PIPELINING>.
+
=head2 Transaction-handling commands
B<Warning:> the behaviour of these commands when combined with pipelining is
View
4 lib/Redis/Hash.pm
@@ -1,7 +1,7 @@
package Redis::Hash;
# ABSTRACT: tie Perl hashes to Redis hashes
-our $VERSION = '1.960'; # VERSION
+our $VERSION = '1.961'; # VERSION
our $AUTHORITY = 'cpan:MELO'; # AUTHORITY
use strict;
@@ -79,7 +79,7 @@ Redis::Hash - tie Perl hashes to Redis hashes
=head1 VERSION
-version 1.960
+version 1.961
=head1 DESCRIPTION
View
4 lib/Redis/List.pm
@@ -1,7 +1,7 @@
package Redis::List;
# ABSTRACT: tie Perl arrays to Redis lists
-our $VERSION = '1.960'; # VERSION
+our $VERSION = '1.961'; # VERSION
our $AUTHORITY = 'cpan:MELO'; # AUTHORITY
use strict;
@@ -99,7 +99,7 @@ Redis::List - tie Perl arrays to Redis lists
=head1 VERSION
-version 1.960
+version 1.961
=head1 SYNOPSYS
View
32 t/04-pipeline.t
@@ -40,7 +40,7 @@ pipeline_ok 'info in pipelined mode',
[info => [], code(sub { ref $_[0] eq 'HASH' && keys %{ $_[0] } })],
[ info => [qw<oops oops>],
undef,
- re(qr/^ERR (?:syntax error|wrong number of arguments for 'info' command)$/)
+ re(qr{^ERR (?:syntax error|wrong number of arguments for 'info' command)$})
],
);
@@ -80,9 +80,37 @@ subtest 'transaction with error and no pipeline' => sub {
is($r->get('clunk'), 'QUEUED', 'transactional GET');
like(
exception { $r->exec },
- qr/\[exec\] ERR Operation against a key holding the wrong kind of value,/,
+ qr{\[exec\] ERR Operation against a key holding the wrong kind of value,},
'synchronous EXEC dies for intervening error'
);
};
+
+subtest 'wait_one_response' => sub {
+ my $first;
+ my $second;
+
+ $r->get('a', sub { $first++ });
+ $r->get('a', sub { $second++ });
+ $r->get('a', sub { $first++ });
+ $r->get('a', sub { $second++ });
+
+ $r->wait_one_response();
+ is($first, 1, 'after first wait_one_response(), first callback called');
+ is($second, undef, '... but not the second one');
+
+ $r->wait_one_response();
+ is($first, 1, 'after second wait_one_response(), first callback was not called again');
+ is($second, 1, '... but the second one was called');
+
+ $r->wait_all_responses();
+ is($first, 2, 'after final wait_all_responses(), first callback was called again');
+ is($second, 2, '... the second one was also called');
+
+ $r->wait_one_response();
+ is($first, 2, 'after final wait_one_response(), first callback was not called again');
+ is($second, 2, '... nor was the second one');
+};
+
+
done_testing();

0 comments on commit b226caf

Please sign in to comment.