Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inability to have multiple bloom filters stored in redis? #3

Closed
smitchelus opened this issue Sep 18, 2013 · 4 comments
Closed

Inability to have multiple bloom filters stored in redis? #3

smitchelus opened this issue Sep 18, 2013 · 4 comments

Comments

@smitchelus
Copy link

Hi, I'm attempting to use your Redis backed bloomfilter, but it appears that it always stores the filter under a hardcoded key called "normalbloomfilter". How can I have a second bloom filter without overwriting the first one?

@DivineTraube
Copy link
Contributor

Hi, thanks for raising the issue. The problem you describe is in fact present, as every Bloomfilter will use the same keys. I will fix it soon.

@smitchelus
Copy link
Author

Cool, thanks!

@ChrisCurtin
Copy link
Contributor

I have submitted a pull request with this feature (Scott and I work together).

@DivineTraube
Copy link
Contributor

The feature is now implemented using the Builder, Bloom filter can now be assigned names, that will be used to distinguish them:

String host = "localhost";
int port = 6379;
String filterName = "normalbloomfilter";
//Open a Redis-backed Bloom filter
BloomFilter<String> bfr = new FilterBuilder(1000, 0.01)
    .name(filterName) //use a distinct name
    .redisBacked(true)
    .redisHost(host) //Default is localhost
    .redisPort(port) //Default is standard 6379
    .buildBloomFilter();

bfr.add("cow");

//Open the same Bloom filter from anywhere else
BloomFilter<String> bfr2 = new FilterBuilder(1000, 0.01)
    .name(filterName) //load the same filter
    .redisBacked(true)
    .buildBloomFilter();
bfr2.add("bison");

print(bfr.contains("cow")); //true
print(bfr.contains("bison")); //true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants