1 Reply Latest reply on Jan 25, 2013 3:42 AM by Tristan Tarrant

    Implementing a custom jdbc cache store

    Ges George Newbie



      I'm looking into using Infinispan as a cache solution for some tick data that I'm dealing with. Unfortunately, I've a requirement to make the data available in a relational database. I'm looking for pointers for implementing a custom cache store to map the cache value's properties to database columns. I can't imagine that this would be very complex, but the I could be wrong. Could you point me to what I should start looking at to implement this - what interfaces should I implement? What would I need to do to support a write behind mode for this store?


      Also, is it possible to enable multiple cache stores? Lets say I want to write synchronously to a file base cache store and asyn to a jdbc cache store? Is this possible?




        • 1. Re: Implementing a custom jdbc cache store
          Tristan Tarrant Master

          Unfortunately the only "guide" for writing custom cache loaders/store is the code itself, which I know is not ideal. We do plan on simplyfing the cachestore SPI greatly in Infinispan 6.0, but that will take time.


          As for your second question: you can have multiple cachestores and they will chained together: the following example is for Infinispan 5.2, but it is easily adaptable to 5.1:





                   <fileStore location="/tmp/mystore">

                      <async enabled="false"/>


                   <stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:5.2">

                      <dataSource jndiUrl="java:/mydatasource" />

                      <stringKeyedTable dropOnExit="false" createOnStart="true" prefix="ISPN">

                         <idColumn name="ID_COLUMN" type="VARCHAR(255)" />

                         <dataColumn name="DATA_COLUMN" type="BINARY(255)" />

                         <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />


                      <async enabled="true"/>