What does HackerNews think of caffeine?

A high performance caching library for Java

Language: Java

Unfortunately, I don't gather statistics on the demonstration server. I believe that the in-memory caffeine cache (https://github.com/ben-manes/caffeine) saved me.
Yeah, saves you from thundering herd problems

https://github.com/ben-manes/caffeine cache does something similar by caching the future that gets returned on look-ups if the value is still being computed

If you need the ability to remove entries, then I would consider the counting Bloom filter (which is simpler, but needs more space), and the cuckoo filter. But you do need to be a bit careful as both can overflow if you are unlucky, or if you add too many entries. In which case you would have to re-build them. So better be prepared for this case, or prevent overflowing the filters by using a cascade of filters.

Some clever cache implementations internally use special kinds of Bloom filters, e.g. the Caffeine cache (Java) uses TinyLFU, which "builds upon Bloom filter theory" (from the abstract of the paper): https://github.com/ben-manes/caffeine and https://arxiv.org/pdf/1512.00727.pdf

(author of Ristretto here) Yeah, I'm surprised not enough people here are talking about Ristretto. It was actually designed with knowledge of the existing Go caches, to deal with their limitations -- based on multiple papers and Caffeine [1], popular in Java world. In particular, achieving higher hit ratios while avoiding contention caused by heavy concurrent access.

This is worth a read: https://blog.dgraph.io/post/introducing-ristretto-high-perf-...

[1]: https://github.com/ben-manes/caffeine

A coworker introduced me to Caffeine which I think shares authors with Guava's cache. Kind of a 2.0 /lessons learned iteration.

https://github.com/ben-manes/caffeine

JDeferred, a promises library, is what CompletableFuture does, a recent addition to Java's standard library in Java 8.

CompletableFuture is becoming supported in a bunch of other libraries: https://github.com/AsyncHttpClient/async-http-client/, https://github.com/ben-manes/caffeine , https://github.com/mp911de/lettuce .

This is sometimes referred to as the "admission policy" of a cache and can have a large effect at increasing the hit ratio.

Most policies try to minimize the impact of low frequency items. For example SLRU uses a small probation space that promotes to a protected region if re-accessed. This allows quickly discarding low frequent items. ARC uses an adaptive version of this idea.

LIRS uses a very small region (HIR) that promotes to a large region (LIR) based in the inter-reference period. This allows it to discard many new arrivals by using a large number of ghosts to retain usage history.

TinyLFU is a probabilistic LFU filter that decides whether to admit by comparing the frequency of the arrival to the victim. This is often near optimal, but can suffer due to sparse bursts causing consecutive misses. An admission window (W-TinyLFU) resolves this problem, usually with a 1% window.

I have a simulator and traces that you could easily add onto to experiment. [1]

I recommend reading the TinyLFU paper as I think it is the best match to your ideas. [2]

[1] https://github.com/ben-manes/caffeine [2] http://arxiv.org/pdf/1512.00727.pdf

Elimination can be enhanced by using a combination strategy, such as DECS [1]. Using a combiner approach should also work on a queue structure, though interestingly enough there is a paper on elimination-based fifo queues. I wrote an elimination stack in Java [2], but I haven't gotten around to adding combining to the arena yet. The performance is pretty good compared to other shared concurrent structures.

[1] http://www.cs.bgu.ac.il/~hendlerd/papers/DECS.pdf [2] https://github.com/ben-manes/caffeine