PHP code example of mdlayher / php-bloomd

1. Go to this page and download the library: Download mdlayher/php-bloomd library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mdlayher / php-bloomd example snippets



// php-bloomd - Example basic usage script
h 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();