AnyEvent-Redis-Federated
view release on metacpan or search on metacpan
lib/AnyEvent/Redis/Federated.pm view on Meta::CPAN
# An AnyEvent-based Redis client which implements timeouts, connection
# retries, multi-machine pool configuration (including consistent
# hashing), and other magic bits.
use strict;
use warnings;
use AnyEvent::Redis;
use AnyEvent;
use Set::ConsistentHash; # for hash ring logic
use Digest::MD5 qw(md5); # for hashing keys
use Scalar::Util qw(weaken);
use List::Util qw(shuffle);
our $VERSION = "0.08";
# keep a global object cache that will contain weak references to
# objects keyed on their tag. this allows for sharing of objects
# within a given process by modules that are otherwise unaware of
# each other provided they use the same tag.
our %object_cache;
lib/AnyEvent/Redis/Federated.pm view on Meta::CPAN
$self->{buckets} = $self->{set}->buckets;
$self->{idle_timeout} = 0 if not exists $self->{idle_timeout};
print "config done.\n" if $self->{debug};
bless $self, $class;
# cache it for later use
if ($self->{tag}) {
$object_cache{$self->{tag}} = $self;
weaken($object_cache{$self->{tag}});
}
return $self;
}
sub removeNode {
my ($self, $node) = @_;
$self->{set}->modify_targets($node => 0);
$self->{buckets} = $self->{set}->buckets;
}
( run in 0.949 second using v1.01-cache-2.11-cpan-65fba6d93b7 )