سؤال

I am using guava bloom filter to remove duplicate message in the service for receiving log. Is there a way for bloom filter to expire like guava cache does?

هل كانت مفيدة؟

المحلول

No, a BloomFilter does not have any remove functionality. This is also impossible, since a BloomFilter keeps track of what may possibly be in a set of objects.

Removing an entry from a BloomFilter for one entry would result into false negatives for other entries. A BloomFilter must be 100% accurate about what is not in the set.

نصائح أخرى

You can't even remove from Guava's BloomFilter, let alone automatically expire entries.

If you need remove functionality consider using a Counting Bloom Filter.

As suggested by Tavian Barnes, one solution here might be to create a class that wraps a BloomFilter and (once a day, or however often you want) atomically replaces that BloomFilter with a new one and repopulates it.

Consider using Sliding Bloom Filters

Check this, This can solve your problem

https://programming.guide/sliding-bloom-filter.html

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top