Stats for cache
I have used core.cache in some of my projects. It is a great library and I liked it a lot. It only lacks stats so I can adjust size of the cache based on some statistics. I have decided to write a custom cache implementation that would allow to get hit/miss stats for the cache. First it was a separate project but then I figured out that I need one change in core.cache itself which I can not hack nicely around. So here is the patch to add stats-aware cache implementation.
core.cache.stats namespace which provides MeasuredCache that implements CacheProtocol and a measured-cache function to instantiate it. MeasuredCache also implements MeasuredCacheProtocol which has only one responsibility - to return snapshot of hit/miss stats
core.cache.stats.counters namespace which provides a protocol (StatsCounterProtocol) that allows to implement hit/miss counters. There are two implementations already: one is based on long wrapped in atom, another one (which is used by default) is based on LongAdder
tests are there for all the methods that could be invoked
Caveats (in no particular order):
LongAdderStatsCounter introduces hard dependency on LongAdder class which was added in java 1.8. I've tried to make it optional but failed (https://stackoverflow.com/questions/45045314/clojure-optional-definitions)
I've modified the defcache macro (all tests pass) so I can actually override definitions
Things to finish before merge:
if you would like the idea I'll add more docs (maybe I should have started with this one so higher chances to be accepted?)
polish code (I'm not an expert in Clojure at all), naming and namespaces
Thank you in advance for the feedback
Still under consideration. I'm looking at a bunch of issues with this library and will include this as part of that with when I've figured out the other hard issues.
Good day. Any updates on this? Anything I can do to help? Thanks
Has added some docs.
Ah, I've asked mostly for contributors page not displaying me issue
I asked Alex to check the recent CAs submitted – I expect he'll be able to confirm next week. It'll take me a while to review and analyze the patch anyway (and I'm neck-deep in production roll-outs right now so be patient).