[infinispan-dev] about cache.getCacheManager()

Mircea Markus mircea.markus at jboss.com
Mon Aug 23 04:32:17 EDT 2010


On 21 Aug 2010, at 00:50, Sanne Grinovero wrote:

> Hello,
> I was quite surprised to see that
> cache.getCacheManager() doesn't return the CacheManager but a
> CacheContainer, which I then need to cast to an EmbeddedCacheManager.
This was introduced with HotRod client. Both embedded and remote (hotrod) caches inherit from the same Cache interface. Also the structure that holds the caches is not a cache manager, but the CacheContainer - that's all that an remote and embedded cache container have in common.  
> Shouldn't the signature of the interface be updated to return a CacheManager ?
I agree this method name is misleading and it breaking the API from 4.0. One thing we can do is:
- make getCacheManger return an EmbeddedCacheManager and deprecate it - to solve backward compatibility
- when called on an RemoteCache this would thrown an exception
- add a method Cache.getCacheContainer that would return an CacheContainer - this would be the suggested approach from now one
> The methods exposed by a CacheContainer are rather useless, especially
> when returned from a cache instance as the only two I could use are
> getCache() and getCache(String cacheName); a use case to explain it
> better:
> 
> ((EmbeddedCacheManager)cache.getCacheManager()).getGlobalConfiguration()
> 
> Cheers,
> Sanne
I see what you mean. I do think that this CacheContainer abstraction has some benefits though: it allows one to write code that doesn't know weather it is using an embedded or a remote cache. 
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev




More information about the infinispan-dev mailing list