Damien Krotkine > Bloomd-Client-0.26 > Bloomd::Client

Download:
Bloomd-Client-0.26.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.26   Source  

NAME ^

Bloomd::Client - Perl client to the bloomd server

VERSION ^

version 0.26

SYNOPSIS ^

  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) );

DESCRIPTION ^

This is a Perl client to connect to the Bloomd server. See http://armon.github.io/bloomd/ for the server website.

ATTRIBUTES ^

protocol

The protocol. ro, defaults to 'tcp'

host

The host to connect to. ro, defaults to '127.0.0.1'

port

The port to connect to. ro, defaults to '8673'

timeout

The timeout (on read and write), in seconds. Can be a float. ro, defaults to 10.

METHODS ^

disconnect

Closes the connection and reset the internal socket

create

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.

list

  my $array_ref = $b->list($prefix?)

Returns an ArrayRef of the existing filters. You can provide a prefix to filter on them.

drop

  $b->drop($name)

Drops a filter. Returns true if the filter existed and was removed properly.

close

  $b->close($name)

Closes a filter. Returns true on success.

clear

  $b->clear($name)

Clears a filter. Returns tru on success.

check

  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).

multi

  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.

set

  $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.

bulk

  $b->bulk($name, $key1, $key2, $key3);

Adds the elements to the given filter. Returns void

info

  my $hash_ref = $b->info($name);

Returns a HashRef giving informations about the given filter name.

flush

  $b->flush($name);

Flushes the filter. Returns true on success.

AUTHOR ^

Damien "dams" Krotkine

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: