NAME
Redis::Namespace - a wrapper of Redis.pm that namespaces all Redis calls
SYNOPSIS
use Redis;
use Redis::Namespace;
my $redis = Redis->new;
my $ns = Redis::Namespace->new(redis => $redis, namespace => 'fugu');
$ns->set('foo', 'bar');
# will call $redis->set('fugu:foo', 'bar');
my $foo = $ns->get('foo');
# will call $redis->get('fugu:foo');
DESCRIPTION
Redis::Namespace is a wrapper of Redis.pm that namespaces all Redis calls. It is useful when you have multiple systems using Redis differently in your app.
OPTIONS
- redis
-
An instance of Redis.pm or Redis::Fast.
- namespace
-
prefix of keys.
- guess
-
If
Redis::Namespacedoesn't known the command, call command info and guess positions of keys. It is boolean value. The default value is false. - strict
-
It is boolean value. If it is true,
Redis::Namespacedoesn't execute unsafe commands which may break another namepace and/or change the state of redis-server, such asFLUSHALLandSHUTDOWN. Also, unknown commands are not executed, because there is no guarantee that the command does not break another namepace. The default value is false.
METHODS
scan_callback
$ns->scan_callback( sub { my $key = shift; ... } );
$ns->scan_callback( match => 'foo:*', sub { my $key = shift; ... } );
Execute a callback exactly once for every matching key within the namespace.
The key is passed as one and only argument to the callback.
AUTHOR
Ichinose Shogo <shogo82148@gmail.com>
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.