Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

mdlayher/php-bloomd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

php-bloomd

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

Example

All commands accepted by bloomd are implemented in php-bloomd. Here is a basic example script.

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

// Establish a connection to a local bloomd with client
$bloomd = new BloomdClient("localhost", 8673);
if (!$bloomd->connect())
{
	printf("example: failed to connect\n");
	exit;
}

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

// Set a couple of values in filter
$bloomd->set("php", "foo");
$bloomd->set("php", "bar");

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

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

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

// Drop filter, disconnect
$bloomd->dropFilter("php");
$bloomd->disconnect();

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages