Simple Guava ForwardingCache I use when developing value loaders

Guava caches are great, but developing with them can be troublesome.

One solution is wrapping the underlying cache using a simple implementation of the ForwardingCache class:

Instead of using a Cache directly from a CacheBuilder, you can wrap it with this class and toggle debug mode.

Note: if you’re using a LoadingCache, you’ll want to derive from the ForwardingLoadingCache instead and override the get(K key) and getAll(Iterable<? extends K> keys) methods as well.