Description:
|
I was grateful to see built-in support for multi-tenancy. We sometimes use EhCache or Memcached for our 2nd level caching. We store slighty different versions of the same objects for each tenant.
Looking at the class org.hibernate.cache.spi.CacheKey, in the EhCache situation, the hashCode will always be the same for all tenants. This forces EhCache to iterate over all tenants with the same object in cache and rely on the equals method to find the correct one. It would seem more efficient to incorporate the tenant id into the hash code.
For Memcached, I rely on the CacheKey.toString() method to create my lookup string. This method doesn't append the tenant id which is now causing a problem of mixing up objects of different tenants. Even if I cast the key to to the CacheKey class, there is no getter method for the tenant id so I could build my own string.
|