2017 © Pedro Peláez
 

library php-bloomd

PHP 5.4+ class for interacting with a bloomd server. MIT Licensed.

image

mdlayher/php-bloomd

PHP 5.4+ class for interacting with a bloomd server. MIT Licensed.

  • Monday, November 18, 2013
  • by mdlayher
  • Repository
  • 3 Watchers
  • 21 Stars
  • 353 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

php-bloomd

PHP 5.4+ class for interacting with a bloomd server (https://github.com/armon/bloomd). MIT Licensed., (*1)

Installation

php-bloomd can be installed via Composer. Add "mdlayher/php-bloomd": "dev-master" to the require section of your composer.json and run composer install., (*2)

Testing

php-bloomd can be tested using PHPUnit. Simply run phpunit test from the project root with a local bloomd server running on port 8673., (*3)

Example

All commands accepted by bloomd are implemented in php-bloomd. Here is a basic example script., (*4)

<?php
// php-bloomd - Example basic usage script
require_once __DIR__ . "/vendor/autoload.php";

// Establish a connection to a local bloomd with client
$bloomd = new PhpBloomd\BloomdClient("localhost", 8673);

// Create a filter
if (!$bloomd->createFilter("php"))
{
    printf("example: failed to create filter\n");
    exit;
}

// Create a filter object to use more concise, object-oriented interface
$filter = $bloomd->filter("php");

// Set a couple of values in filter, using both BloomdClient and direct BloomFilter
// Either method may be used for all functions which accept a filter name as first parameter
$bloomd->set("php", "foo");
$filter->set("bar");

// Check the filter for membership
if ($bloomd->check("php", "foo"))
{
    printf("example: got it!\n");
}

// Bulk set values
$results = $filter->bulk(array("foo", "bar", "baz"));
foreach ($results as $k => $v)
{
    printf("%s -> %s\n", $k, $v ? "true" : "false");
}

// Multi check values
$results = $filter->multi(array("foo", "bar", "baz"));
foreach ($results as $k => $v)
{
    printf("%s -> %s\n", $k, $v ? "true" : "false");
}

// Check for any value in array
if ($filter->any(array("foo", "qux")))
{
    printf("any: yes!\n");
}

// Check for all values in array
if ($filter->all(array("foo", "bar", "baz")))
{
    printf("all: yes!\n");
}

// Drop filter
$filter->dropFilter();

The Versions

18/11 2013

dev-master

9999999-dev https://github.com/mdlayher/php-bloomd

PHP 5.4+ class for interacting with a bloomd server. MIT Licensed.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

bloomd

11/11 2013

1.0

1.0.0.0 https://github.com/mdlayher/php-bloomd

PHP 5.4+ class for interacting with a bloomd server. MIT Licensed.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

bloomd