Custom Eviction Policy and JDBC Cache loader
jorgemoralespou_2 Sep 3, 2008 1:23 PMI want to achive this behaviour:
Have a cache with a JDBCCacheLoade for secondary storage
Have some regions configured to evict nodes, and some to remove
Only have in secondary storage nodes being evicted, once, and only once, they have been evicted
For this, I have done a custom eviction Policy to remove data from cache, as related in here. I have configured a default eviction Policy for the cache, and region eviction policies for different regions, if they have to bee persisted with a normal eviction policy, if they have to be removed with a custom remove policy.
What I experience is that my data is being written to secondary storage as soon as I write into cache, and once the eviction work runs, it removes data from database that has the custom remove policy.
Question is:
How can I configure caches, to only persist when eviction policy is run?
Cache version is a custom patched JBC1.4.1.SP9.
Here is my config.
<server> <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar" /> <mbean code="com.xxx.cache.core.mbean.ServiceDataCacheWithListener" name="jboss.cache:service=XXXServicesDataCache"> <depends>jboss:service=Naming</depends> <depends> jboss.jca:name=jdbc/somservices,service=DataSourceBinding </depends> <attribute name="IsolationLevel">NONE</attribute> <attribute name="CacheMode">REPL_ASYNC</attribute> <attribute name="UseReplQueue">false</attribute> <attribute name="ReplQueueInterval">0</attribute> <attribute name="ReplQueueMaxElements">0</attribute> <attribute name="ClusterName"> SOMServicesCache-Cluster </attribute> <attribute name="ClusterProperties">file:///opt/cache-config.xml</attribute> <attribute name="FetchInMemoryState">${cache.service-data.fetch-in-memory:true}</attribute> <attribute name="InitialStateRetrievalTimeout">${cache.service-data.state-retrieval-timeout:15000}</attribute> <attribute name="SyncReplTimeout">2000</attribute> <attribute name="LockAcquisitionTimeout">10000</attribute> <attribute name="EvictionPolicyClass"> org.jboss.cache.eviction.LRUPolicy </attribute> <attribute name="EvictionPolicyConfig"> <config> <attribute name="wakeUpIntervalSeconds">30</attribute> <region name="/_default_"> <attribute name="maxNodes">100000</attribute> <attribute name="timeToLiveSeconds">86400</attribute> </region> </config> </attribute> <attribute name="UseRegionBasedMarshalling">true</attribute> <attribute name="InactiveOnStartup">false</attribute> <attribute name="CacheLoaderConfiguration"> <config> <passivation>false</passivation> <preload>/</preload> <shared>true</shared> <cacheloader> <class> org.jboss.cache.loader.ClusteredCacheLoader </class> <properties>timeout=30000</properties> <async>true</async> <fetchPersistentState>false</fetchPersistentState> <ignoreModifications>false</ignoreModifications> </cacheloader> <cacheloader> <class>org.jboss.cache.loader.MyJDBCTimestampCacheLoader</class> <properties> cache.jdbc.datasource=java:jdbc/services cache.jdbc.table.name=service_data cache.jdbc.table.create=true cache.jdbc.table.drop=false cache.jdbc.table.primarykey=service_data_pk cache.jdbc.fqn.column=fqn cache.jdbc.fqn.type=varchar(255) cache.jdbc.node.column=node cache.jdbc.node.type=blob cache.jdbc.parent.column=parent cache.jdbc.timestamp.column=timestamp cache.jdbc.timestamp.type=timestamp </properties> <async>true</async> <fetchPersistentState>true</fetchPersistentState> <ignoreModifications>false</ignoreModifications> </cacheloader> </config> </attribute> </mbean> </server>