I currently have a Guava cache where I know certain values come up from multiple keys:
Key1 -> ValueA
Key2 -> ValueB
Key3 -> ValueA
This is due to poor key design, but I need to scope out the problem and get a good idea of how many keys point to similar values.
My first idea is to create a new Guava cache where the keys are the values of the first cache, and the values are the number of occurrences of that value in the first cache. So for the above cache, it would be:
ValueA -> 2
ValueB -> 1
That would offer good insight into the number of keys that are duplicated and how to optimize them.
However, where I hit the roadblock is that I am not sure how to implement the second cache. I would need the value to be incremented each time the cache is accessed, and I don’t really know if there’s any way to support that in Guava.