The JCacheRegionFactory will create anonymous, poorly configured caches if one wasn't registered with the JCache provider. Perhaps this was chosen to be similar to JCache's annotation support that does the same thing. By quietly doing bad things the initial experience might be nice in a demo, but production quality is harmed due to poor performance and memory leaks. The default configuration requires that the cache serialize the key/value when it crosses the API boundary. Unless configured separately, the provider is most likely to use Java serialization for best compatibility and warn users to prefer a more appropriate (faster) mechanism in their documentation. As well documented, Java serialization is very slow. The default configuration does not evict or expire entries, and does not enable any statistic monitoring. Therefore the unbounded cache may be hidden until discovered when investigating memory leaks. Ehcache contributed the JCache adapter. In their samples they now explicitly disallow anonymous caches. Perhaps @henri_tremblay can speak on their behalf. This request is to minimally add a logging statement warning the user when an anonymous cache is created. Preferably this behavior would not be allowed, like in the Ehcache sample, to avoid code that only benefits presenters and is harmful to actual users. |