4 |
use strict; |
use strict; |
5 |
|
|
6 |
use IO::Socket::INET; |
use IO::Socket::INET; |
7 |
use Data::Dump qw/dump/; |
use Data::Dumper; |
8 |
use Carp qw/confess/; |
use Carp qw/confess/; |
9 |
|
|
10 |
=head1 NAME |
=head1 NAME |
13 |
|
|
14 |
=cut |
=cut |
15 |
|
|
16 |
our $VERSION = '0.0801'; |
our $VERSION = '1.2001'; |
17 |
|
|
18 |
|
|
19 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
20 |
|
|
21 |
Pure perl bindings for L<http://code.google.com/p/redis/> |
Pure perl bindings for L<http://code.google.com/p/redis/> |
22 |
|
|
23 |
This version support git version 0.08 or later of Redis available at |
This version supports protocol 1.2 or later of Redis available at |
24 |
|
|
25 |
L<git://github.com/antirez/redis> |
L<git://github.com/antirez/redis> |
26 |
|
|
61 |
sadd => 1, srem => 1, |
sadd => 1, srem => 1, |
62 |
sismember => 1, |
sismember => 1, |
63 |
echo => 1, |
echo => 1, |
64 |
|
getset => 1, |
65 |
|
smove => 1, |
66 |
|
zadd => 1, |
67 |
|
zrem => 1, |
68 |
|
zscore => 1, |
69 |
|
zincrby => 1, |
70 |
|
append => 1, |
71 |
}; |
}; |
72 |
|
|
73 |
# we don't want DESTROY to fallback into AUTOLOAD |
# we don't want DESTROY to fallback into AUTOLOAD |
77 |
sub AUTOLOAD { |
sub AUTOLOAD { |
78 |
my $self = shift; |
my $self = shift; |
79 |
|
|
80 |
|
use bytes; |
81 |
|
|
82 |
my $sock = $self->{sock} || die "no server connected"; |
my $sock = $self->{sock} || die "no server connected"; |
83 |
|
|
84 |
my $command = $AUTOLOAD; |
my $command = $AUTOLOAD; |
85 |
$command =~ s/.*://; |
$command =~ s/.*://; |
86 |
|
|
87 |
warn "## $command ",dump(@_) if $self->{debug}; |
warn "## $command ",Dumper(@_) if $self->{debug}; |
88 |
|
|
89 |
my $send; |
my $send; |
90 |
|
|
135 |
} |
} |
136 |
|
|
137 |
if ( $type eq '-' ) { |
if ( $type eq '-' ) { |
138 |
confess $result; |
confess "[$command] $result"; |
139 |
} elsif ( $type eq '+' ) { |
} elsif ( $type eq '+' ) { |
140 |
return $result; |
return $result; |
141 |
} elsif ( $type eq '$' ) { |
} elsif ( $type eq '$' ) { |
156 |
my $v; |
my $v; |
157 |
if ( $len > 0 ) { |
if ( $len > 0 ) { |
158 |
read($self->{sock}, $v, $len) || die $!; |
read($self->{sock}, $v, $len) || die $!; |
159 |
warn "<< ",dump($v),$/ if $self->{debug}; |
warn "<< ",Dumper($v),$/ if $self->{debug}; |
160 |
} |
} |
161 |
my $crlf; |
my $crlf; |
162 |
read($self->{sock}, $crlf, 2); # skip cr/lf |
read($self->{sock}, $crlf, 2); # skip cr/lf |
175 |
$list[ $_ ] = $self->__read_bulk( substr(<$sock>,1,-2) ); |
$list[ $_ ] = $self->__read_bulk( substr(<$sock>,1,-2) ); |
176 |
} |
} |
177 |
|
|
178 |
warn "## list = ", dump( @list ) if $self->{debug}; |
warn "## list = ", Dumper( @list ) if $self->{debug}; |
179 |
return @list; |
return @list; |
180 |
} |
} |
181 |
|
|
419 |
|
|
420 |
=head1 COPYRIGHT & LICENSE |
=head1 COPYRIGHT & LICENSE |
421 |
|
|
422 |
Copyright 2009 Dobrica Pavlinusic, all rights reserved. |
Copyright 2009-2010 Dobrica Pavlinusic, all rights reserved. |
423 |
|
|
424 |
This program is free software; you can redistribute it and/or modify it |
This program is free software; you can redistribute it and/or modify it |
425 |
under the same terms as Perl itself. |
under the same terms as Perl itself. |