AnyEvent-Redis
view release on metacpan or search on metacpan
README
t/00_compile.t
t/client.t
t/leak.t
t/lrange.t
t/multi.t
t/pubsub.t
t/reconnect.t
t/redis.conf.base
t/Redis.pm
t/utf8.t
xt/perlcritic.t
xt/pod.t
xt/podspell.t
xt/synopsis.t
NAME
AnyEvent::Redis - Non-blocking Redis client
SYNOPSIS
use AnyEvent::Redis;
my $redis = AnyEvent::Redis->new(
host => '127.0.0.1',
port => 6379,
encoding => 'utf8',
on_error => sub { warn @_ },
on_cleanup => sub { warn "Connection closed: @_" },
);
# callback based
$redis->set( 'foo'=> 'bar', sub { warn "SET!" } );
$redis->get( 'foo', sub { my $value = shift } );
my ($key, $value) = ('list_key', 123);
$redis->lpush( $key, $value );
attributes:
host => <HOSTNAME>
Required. The hostname or literal address of the server.
port => <PORT>
Optional. The server port.
encoding => <ENCODING>
Optional. Encode and decode data (when storing and retrieving,
respectively) according to *ENCODING* ("utf8" is recommended or see
Encode::Supported for details on possible *ENCODING* values).
Omit if you intend to handle raw binary data with this connection.
on_error => $cb->($errmsg)
Optional. Callback that will be fired if a connection or
database-level error occurs. The error message will be passed to the
callback as the sole argument.
on_cleanup => $cb->($errmsg)
lib/AnyEvent/Redis.pm view on Meta::CPAN
AnyEvent::Redis - Non-blocking Redis client
=head1 SYNOPSIS
use AnyEvent::Redis;
my $redis = AnyEvent::Redis->new(
host => '127.0.0.1',
port => 6379,
encoding => 'utf8',
on_error => sub { warn @_ },
on_cleanup => sub { warn "Connection closed: @_" },
);
# callback based
$redis->set( 'foo'=> 'bar', sub { warn "SET!" } );
$redis->get( 'foo', sub { my $value = shift } );
my ($key, $value) = ('list_key', 123);
$redis->lpush( $key, $value );
lib/AnyEvent/Redis.pm view on Meta::CPAN
B<Required.> The hostname or literal address of the server.
=item port => <PORT>
Optional. The server port.
=item encoding => <ENCODING>
Optional. Encode and decode data (when storing and retrieving, respectively)
according to I<ENCODING> (C<"utf8"> is recommended or see L<Encode::Supported>
for details on possible I<ENCODING> values).
Omit if you intend to handle raw binary data with this connection.
=item on_error => $cb->($errmsg)
Optional. Callback that will be fired if a connection or database-level error
occurs. The error message will be passed to the callback as the sole argument.
=item on_cleanup => $cb->($errmsg)
test_redis {
my $r = shift;
$r->all_cv->begin(sub { $_[0]->send });
my $info = $r->info->recv;
is ref $info, 'HASH';
ok $info->{redis_version};
{
use utf8;
my $key = "ã㸠ããã»ã¹ã";
my $val = "लà¤à¤à¤¨à¤¹à¤¿";
$r->set($key => $val, sub { pass "SET literal UTF-8 key/value" });
$r->get($key, sub {
is $_[0], $val, "GET literal UTF-8 key/value";
});
}
my $utf8_key = "\x{a3}\x{acd}";
my $utf8_val = "\x{90e}\x{60a}";
$r->set($utf8_key => $utf8_val, sub {
pass "SET escaped UTF-8 key/value"
});
$r->get($utf8_key, sub {
is $_[0], $utf8_val, "GET escaped UTF-8 key/value";
});
my $latin1_key = "V\x{f6}gel";
my $latin1_val = "Gr\x{fc}n";
$r->set($latin1_key => $latin1_val, sub {
pass "SET escaped Latin-1 key/value"
});
$r->get($latin1_key, sub {
is $_[0], $latin1_val, "GET escaped Latin-1 key/value";
});
$r->all_cv->end;
$r->all_cv->recv;
eval { AnyEvent::Redis->new(encoding => "invalid") };
like $@, qr/Encoding "invalid" not found/;
}
# Extra args for the constructor
{ encoding => "utf8" };
done_testing;
# vim:fileencoding=utf8
( run in 0.534 second using v1.01-cache-2.11-cpan-49f99fa48dc )