[infinispan-dev] CacheContainer.getCache

Manik Surtani manik at jboss.org
Wed Dec 1 06:10:49 EST 2010


On 1 Dec 2010, at 10:30, Galder Zamarreño wrote:

> 
> On Nov 30, 2010, at 7:00 PM, Mircea Markus wrote:
> 
>> Hi,
>> 
>> if there is no such cache defined in the configuration with name "undefinedCacheName" and CacheContainer.getCache("undefinedCacheName") is called then an cache with default configuration and that name is first defined and then instantiated and returned. 
>> Anyone remembers what the requirement were for this is?
>> IMO an exception should be thrown and user should be notified that the cache is not defined. This way we can fail fast e.g. If the user forgets to define a cache or misspells its name.
>> If this behaviour is needed, an approach would be to create an specialised method to handle this: getAndDefineCache...
> 
> I can't remember about the req, but it could make sense to differentiate between the two cases. I think someone else provided similar feedback a few months ago.

We allow lazy definition of such caches via the programmatic API (e.g., for embedded caches) only.  Not for remote protocols.  E.g., there is no way to define and use a new cache instance via REST or Hot Rod.

> I do think though that getCache should remain as is, and instead have a separate method that gets only if defined.

+1.


--
Manik Surtani
manik at jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org







More information about the infinispan-dev mailing list