Skip navigation links

Infinispan SQL cache store v2.5

Cache loader / writer for an SQL database backend.

See: Description

Packages 
Package Description
com.nimbusds.infinispan.persistence.sql
SQL store for Infinispan 8.2+ caches and maps.
com.nimbusds.infinispan.persistence.sql.config
Configuration classes.
com.nimbusds.infinispan.persistence.sql.query
SQL query executor interfaces.
com.nimbusds.infinispan.persistence.sql.transformers
Transformation utilities for Java collections and other complex classes.

Cache loader / writer for an SQL database backend.

Requirements

Features

Usage

  1. Add the Maven dependency for the SQL cache store, or make sure its JAR is present in the CLASSPATH of your project.
  2. Implement SQLRecordTransformer to translate between Infinispan entries (key / value pairs with optional metadata) and SQL records.
  3. Configure an SQL store for each Infinispan cache that requires one, by setting the properties specified in SQLStoreConfiguration. Also, see the example below. Note that the SQL store can safely shared between multiple replicated / distributed instances of a cache. It can also be used in read-only mode.

Maven

Maven coordinates:

    <groupId>com.nimbusds</groupId>
    <artifactId>infinispan-cachestore-sql</artifactId>
    <version>[ version ]</version>

where [ version ] should be the latest stable version.

Example configuration

Example Infinispan configuration for a cache backed by an H2 SQL database:

<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:infinispan:config:8.2 http://www.infinispan.org/schemas/infinispan-config-8.2.xsd"
            xmlns="urn:infinispan:config:8.2"
            xmlns:sql="urn:infinispan:config:store:sql:2.2">

    <cache-container name="myCacheContainer" default-cache="myMap" statistics="true">
        <jmx duplicate-domains="true"/>
        <local-cache name="myMap">
            <eviction type="COUNT" size="100"/>
            <persistence passivation="false">
                <sql-store xmlns="urn:infinispan:config:store:sql:2.2"
                           shared="true"
                           record-transformer="com.nimbusds.infinispan.persistence.sql.UserRecordTransformer"
                           sql-dialect="H2">

                    <property name="jdbcUrl">jdbc:h2:mem:test;DATABASE_TO_UPPER=false</property>
                    <property name="username">admin</property>
                    <property name="password">secret</property>

                </sql-store>
            </persistence>
        </local-cache>
    </cache-container>

</infinispan>
Skip navigation links

Copyright © 2016 Connect2id Ltd.. All Rights Reserved.