2 Replies Latest reply on Mar 2, 2010 6:16 AM by Galder Zamarreño

    Flushing data to disk

    ravendra kumar Newbie

      Hi,

      I am new to JBossCache!

       

      I want to store a lot of records in local cache,

      My basic requrement is, when i am storing data in cache,  after reaching to  limits, cache should be able to flush data on disk for later retrieval.

      can someone suggest me minimal configuraion as an example, because I am little confuse with cache loder and evection policy configuration

        • 1. Re: Flushing data to disk
          Mircea Markus Master

          you should have eviction enabled and a cache loader with passivation.

              <eviction wakeUpInterval="500">

                  <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">

                      <property name="maxNodes" value="5000"/>

                      <property name="timeToLive" value="1000"/>

                  </default>

                  <region name="/org/jboss/data1">

                      <property name="timeToLive" value="2000"/>

                  </region>

                  <region name="/org/jboss/data2" algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000">

                      <property name="maxNodes" value="3000"/>

                      <property name="minTimeToLive" value="4000"/>

                  </region>

              </eviction>

           

              <!--

                 Cache loaders.

           

                 If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted.  Similarly, when the state

                 is accessed again, it is removed from the cache loader and loaded into memory.

           

                 Otherwise, state is always maintained in the cache loader as well as in memory.

           

                 Set 'shared' to true if all instances in the cluster use the same cache loader instance, e.g., are talking to the

                 same database.

              -->

              <loaders passivation="true" shared="false">

                  <preload>

                      <node fqn="/org/jboss"/>

                      <node fqn="/org/tempdata"/>

                  </preload>

           

                  <!--

                     we can have multiple cache loaders, which get chained

                  -->

                  <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true"

                          ignoreModifications="true" purgeOnStartup="true">

           

                      <properties>

                          cache.jdbc.table.name=jbosscache

                          cache.jdbc.table.create=true

                          cache.jdbc.table.drop=true

                          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=BINARY

                          cache.jdbc.parent.column=parent

                          cache.jdbc.driver=org.hsqldb.jdbcDriver

                          cache.jdbc.url=jdbc:hsqldb:mem:jbosscache

                          cache.jdbc.user=sa

                          cache.jdbc.password=

                      </properties>

                      <!-- alternatively use a connection from a datasorce, as per the code sample below-->

                      <!--<properties>-->

                      <!--cache.jdbc.datasource=AllSampleDS-->

                      <!--cache.jdbc.table.name=jbosscache-->

                      <!--cache.jdbc.table.create=true-->

                      <!--cache.jdbc.table.drop=true-->

                      <!--</properties>-->

                      <singletonStore enabled="true" class="org.jboss.cache.loader.SingletonStoreCacheLoader">

                          <properties>

                              pushStateWhenCoordinator=true

                              pushStateWhenCoordinatorTimeout=20000

                          </properties>

                      </singletonStore>

                  </loader>

              </loaders>

          • 2. Re: Flushing data to disk
            Galder Zamarreño Master
            If you want to use even simpler configuration, use Infinispan