[jboss-user] [JBossCache] - Re: Cache loader questions

aditsu do-not-reply at jboss.com
Fri Nov 23 03:51:56 EST 2007


Hi, I think you're wrong about point 1. I wrote a simple test:

package aditsu;
  | 
  | import java.io.IOException;
  | import java.util.HashMap;
  | import java.util.Map;
  | 
  | import org.apache.log4j.BasicConfigurator;
  | import org.jboss.cache.Cache;
  | import org.jboss.cache.DefaultCacheFactory;
  | import org.jboss.cache.Fqn;
  | 
  | public class JDBCTest {
  | 	
  | 	public static void main(final String... args) throws IOException {
  | 		BasicConfigurator.configure();
  | 		Cache c = DefaultCacheFactory.getInstance().createCache("aditsu/cache-jdbc.xml");
  | 		Map m = new HashMap();
  | 		c.put(new Fqn("a"), m);
  | 		c.put(new Fqn("b"), m);
  | 		c.put(new Fqn("c"), m);
  | 		c.stop();
  | 		c.destroy();
  | 		System.in.read();
  | 		c.create();
  | 		c.start();
  | 	}
  | }

and this is my cache config:

<?xml version="1.0" encoding="UTF-8"?>
  | 
  | <server>
  |     <mbean code="org.jboss.cache.jmx.CacheJmxWrapper" name="jboss.cache:service=TreeCache">
  |         <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.DummyTransactionManagerLookup</attribute>
  |         <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
  |         <attribute name="CacheMode">LOCAL</attribute>
  | 		<attribute name="CacheLoaderConfig">
  | 		<config>
  | 			<passivation>false</passivation>
  | 			<preload>/</preload>
  | 			<cacheloader>
  | 			<class>org.jboss.cache.loader.JDBCCacheLoader</class>
  | 			<properties>
  | 			cache.jdbc.table.name=jbosscache
  | 			cache.jdbc.table.create=true
  | 			cache.jdbc.table.drop=false
  | 			cache.jdbc.table.primarykey=jbosscache_pk
  | 			cache.jdbc.fqn.column=fqn
  | 			cache.jdbc.fqn.type=varchar(255)
  | 			cache.jdbc.node.column=node
  | 			cache.jdbc.node.type=bytea
  | 			cache.jdbc.parent.column=parent
  | 			cache.jdbc.driver=org.postgresql.Driver
  | 			cache.jdbc.url=jdbc:postgresql://localhost/jbc
  | 			cache.jdbc.user=postgres
  | 			cache.jdbc.password=
  | 			cache.jdbc.sql-concat=concat(1,2)
  | 			</properties>
  | 			<async>false</async>
  | 			<fetchPersistentState>true</fetchPersistentState>
  | 			<ignoreModifications>false</ignoreModifications>
  | 			<purgeOnStartup>false</purgeOnStartup>
  | 			</cacheloader>
  | 		</config>
  | 		</attribute>
  |     </mbean>
  | </server>

When I start the cache the 2nd time (after pressing enter), I get these log entries:

5226 [main] DEBUG org.jboss.cache.loader.JDBCCacheLoader  - executing sql: select node from jbosscache where fqn=? (/)
5229 [main] DEBUG org.jboss.cache.CacheImpl.JBossCache-Cluster  - cache mode is local, will not create the channel
5229 [main] DEBUG org.jboss.cache.loader.CacheLoaderManager  - preloading transient state from cache loader org.jboss.cache.loader.JDBCCacheLoader at 39ab89
5229 [main] DEBUG org.jboss.cache.loader.JDBCCacheLoader  - executing sql: select fqn from jbosscache where parent=? (/)
5232 [main] DEBUG org.jboss.cache.loader.JDBCCacheLoader  - executing sql: select node from jbosscache where fqn=? (/a)
5235 [main] DEBUG org.jboss.cache.loader.JDBCCacheLoader  - executing sql: select fqn from jbosscache where parent=? (/a)
5238 [main] DEBUG org.jboss.cache.loader.JDBCCacheLoader  - executing sql: select node from jbosscache where fqn=? (/c)
5241 [main] DEBUG org.jboss.cache.loader.JDBCCacheLoader  - executing sql: select fqn from jbosscache where parent=? (/c)
5245 [main] DEBUG org.jboss.cache.loader.JDBCCacheLoader  - executing sql: select node from jbosscache where fqn=? (/b)
5266 [main] DEBUG org.jboss.cache.loader.JDBCCacheLoader  - executing sql: select fqn from jbosscache where parent=? (/b)

So it's executing not one but TWO queries for every single node! That's definitely not what I want, and contradicts what you said.

Adrian

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

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



More information about the jboss-user mailing list