[jboss-dev-forums] [Design of JBossCache] - JBCACHE-1004 and JBCACHE-1005

manik.surtani@jboss.com do-not-reply at jboss.com
Mon Mar 12 14:03:02 EDT 2007


For the next beta of JBoss Cache 2.0.0, I've taken the public APIs a step further by genericising them.  

This is in CVS right now.  Feedback on this new, genericised API is much appreciated.

Affected classes/interfaces are:  Cache, CacheSPI, Node, NodeSPI, Fqn, CacheFactory.

My reasoning behind genericising has been that while a lot of people would still want a cache that holds generic Objects, certain degree of control as to the type can be useful.  For example, enforcing the elements that make up an Fqn or what objects can be used as keys.  

One of the issues here is that if you decide to specify what you want in your cache (keys and values) you'd need to specify this when creating the cache using the cache factory, and these types are then used whenever Nodes are created.  

Typical usage pattern:


  | 
  | // example where we want all keys to be integers and all the objects in the cache are Strings.
  | CacheFactory<Integer, String> cf = DefaultCacheFactory.getInstance();
  | Cache<Integer, String> cache = cf.createCache();
  | 
  | Fqn<String> myFqn = Fqn.fromString("/a/b/c");
  | Node<Integer, String> node = cache.getRoot().getChild(myFqn);
  | 
  | node.put(33, "Hello world");
  | 

Does this relative inflexibility mean that most people would just create Cache<Object, Object> anyway?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4027284#4027284

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4027284



More information about the jboss-dev-forums mailing list