On 17 May 2018 at 11:11, Sanne Grinovero <sa...@hibernate.org> wrote: > I think this is the RegionFactory's responsibility, as Hibernate ORM > alone can't know if this is necessary. > > Prefixing is one of many options to isolate caches; a Cache technology > might wish to use a different approach by implementing a custom > `org.hibernate.cache.spi.CacheKeysFactory`.
Hum, I regret how I wrote the above paragraph. I actually meant that a Cache technology could implement isolation in many different ways. Using a custom `CacheKeysFactory` is just an example, there are many other options as well. In fact, I believe a good choice for application servers would be to have an independent CacheManager for each deployment. Then it can safely inspect the deployment, see if there are multiple Persistence Units using the same caching technology, and implement further isolation only if necessary. These thoughts are a consequence of a chat I had with Paul Ferraro from the WildFly team, as he mentioned the size of the keys becoming problematic with all the additional prefixing they need to apply. I hope this will make it possible to e.g. create an "as small as possible" unique identifier for the deployments to replace the deployment name during serialization (to identify the CacheManager) followed by a numeric id indexing the PUs within the deployment - or nothing altogether in case of single PUs. Of course, I don't expect that to be needed right away; the RegionFactory could just do good old prefixing for now but I hope we'll explore such improvements in the near future. Thanks, Sanne > > Not least the server / deployer might be able to hint the Cache > provider to tell if isolation is at all necessary. > > In conclusion, by having Hibernate ORM not messing with prefixes > allows other technologies to implement more efficient solutions. Our > own code also ends up being more efficient by not needing to add a > prefix during each and every access to the cache. > > Thanks, > Sanne > > On 17 May 2018 at 06:34, Gail Badner <gbad...@redhat.com> wrote: >> I see that cache region names are not being prefixed in 5.3. >> >> EnabledCaching sets the TimestampsRegion region name >> to TimestampsRegion.class.getName(), and sets the QueryResultsRegion region >> name to QueryResultsRegion.class.getName(). [1] >> >> Without a prefix, WildFly is failing intermittently when there are 2 >> persistence units with the query cache enabled due to: >> >> org.infinispan.commons.CacheConfigurationException: ISPN000453: Attempt to >> define configuration for cache org.hibernate.cache.spi.TimestampsRegion >> which already exists >> >> Entity region names are not being prefixed either. >> >> Should they be prefixed by Hibernate or by the RegionFactory? >> >> Regards, >> Gail >> >> [1] >> https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/cache/internal/EnabledCaching.java#L80-L92 >> _______________________________________________ >> hibernate-dev mailing list >> hibernate-dev@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/hibernate-dev _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev