1. Go to this page and download the library: Download denismitr/laravel-bloom 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/ */
public function someAction(Denismitr\Bloom\BloomManager $bloomManager)
{
$bloomFilter = $bloomManager->key('foo');
$bloomFilter->add('baz');
...
$bloomFilter->test('baz'); // true
...
$bloomFilter->clear(); // clear bloom filter under 'foo' key
}
Bloom::key("shown-banners")->add($banner->id);
...
Bloom::key("shown-banners")->test($banner->id);
// true
Bloom::key("shown-banners")->test($unseenBanner->id);
// false, but can be true sometimes (a false positive)
// reset bloom filter for given key
Bloom::key('shown-banners')->reset();
$bloomFilter = Bloom::key('user-recommendation', $user->id);
$bloomFilter->add($recommendation->id);
$bloomFilter->test($recommendation->id); // true
// to clear that key do
$bloomFilter->clear();