[jboss-user] [JBoss Cache: Core Edition] - CacheLoader does not load a node if its parent has been dele

kblanken do-not-reply at jboss.com
Wed Jun 11 08:06:37 EDT 2008

In our application, we need to remove some nodes (FQNs) from the cache before reinserting them. We do not know which nodes must be removed exactly, so we just remove their nearest FQN parent. The nodes are loaded using a CacheLoader later in the same transaction.

For simplicity, let's say we have a cache instance called "cache" that is configured to use a custom CacheLoader that always returns "value from CacheLoader". Starting with an empty cache we call:

  | String val = (String) cache.get("/a/b/c", "key");
  | assertEquals("value from CacheLoader", val);

The result will be null instead of "value from CacheLoader".

This is because the parent node of the new key is put into the TransactionEntry's list of cache loader modifications when remove() is called. In the CacheLoaderInterceptor.invoke() method, the list is checked before loading the node:

if (!initNode && !wasRemovedInTx(fqn))
  | {
  |     n = loadNode(fqn, n, entry);
  | }

Here, wasRemovedInTx returns true although the node has never been loaded before. As a result, the node is not loaded by the cache loader.

JBC version is 1.4.1 SP9.
Are we doing something wrong here?



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

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

More information about the jboss-user mailing list