Bloomd::Client - Perl client to the bloomd server
version 0.25
use feature ':5.12'; use Bloomd::Client; my $b = Bloomd::Client->new( timeout => 0.2 ); my $filter = 'test_filter'; $b->create($filter); my $array_ref = $b->list(); my $hash_ref = $b->info($filter); $b->set($filter, 'u1'); if ($b->check($filter, 'u1')) { say "it exists!" } my $hashref = $b->multi( $filter, qw(u1 u2 u3) );
This is a Perl client to connect to the Bloomd server. See http://armon.github.io/bloomd/ for the server website.
The protocol. ro, defaults to 'tcp'
The host to connect to. ro, defaults to '127.0.0.1'
The port to connect to. ro, defaults to '8673'
The timeout (on read and write), in seconds. Can be a float. ro, defaults to 10.
Closes the connection and reset the internal socket
Creates a new bloom filter
$b->create($name, $capacity?, $probability?, $in_memory=0|1?)
Only the name is mandatory. You can specify the initial capacity (if not the filter will be enlarged as needed), the probability of maximum false positives you want, and a flag to force the filter to not be in memory (by default it is).
Returns true if the filter didn't exist and was created successfully.
my $array_ref = $b->list($prefix?)
Returns an ArrayRef of the existing filters. You can provide a prefix to filter on them.
$b->drop($name)
Drops a filter. Returns true if the filter existed and was removed properly.
$b->close($name)
Closes a filter. Returns true on success.
$b->clear($name)
Clears a filter. Returns tru on success.
if ($b->check($name, $key)) { print "the element $key matched\n"; }
Given a filter name and a key name, returns true if the key was previously added in the filter (using set).
set
my $hash_ref = $b->multi($name, $key1, key2, key3);
Given a filter name and a list of elements, returns a HashRef, which keys are the elements, and the values are 1 or 0, depending if the element is present in the filter or not.
$b->set($name, $key);
Adds the element to the given filter. Returns 1 if the elements was not previously in the filter and was properly added.
$b->bulk($name, $key1, $key2, $key3);
Adds the elements to the given filter. Returns void
my $hash_ref = $b->info($name);
Returns a HashRef giving informations about the given filter name.
$b->flush($name);
Flushes the filter. Returns true on success.
Damien "dams" Krotkine
This software is copyright (c) 2013 by Damien "dams" Krotkine.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Bloomd::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bloomd::Client
CPAN shell
perl -MCPAN -e shell install Bloomd::Client
For more information on module installation, please visit the detailed CPAN module installation guide.