此内容没有您所选择的语言版本。

15.2.2. JdbcStringBasedStore Configuration (Library Mode)


The following is a sample configuration for the JdbcStringBasedStore:

Procedure 15.5. Configure JdbcStringBasedStore in Library Mode

  1. The stringKeyedJdbcStore Element

    The stringKeyedJdbcStore element uses the following parameters to configure the cache store:
    1. The fetchPersistentState parameter determines whether the persistent state is fetched when joining a cluster. Set this to true if using a replication and invalidation in a clustered environment. Additionally, if multiple cache stores are chained, only one cache store can have this property enabled. If a shared cache store is used, the cache does not allow a persistent state transfer despite this property being set to true. The fetchPersistentState parameter is false by default.
    2. The ignoreModifications parameter determines whether operations that modify the cache (e.g. put, remove, clear, store, etc.) do not affect the cache store. As a result, the cache store can become out of sync with the cache.
    3. The purgeOnStartup parameter specifies whether the cache is purged when initially started.
    4. The key2StringMapper parameter specifies the class name of the Key2StringMapper used to map keys to strings for the database tables.
    <infinispan
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
            xmlns="urn:infinispan:config:6.0">
            ...
    <persistence>
    	<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
    	                      fetchPersistentState="false"
    			      ignoreModifications="false" 
    			      purgeOnStartup="false"
    			      key2StringMapper="org.infinispan.loaders.keymappers.DefaultTwoWayKey2StringMapper">
    
    Copy to Clipboard Toggle word wrap
  2. The connectionPool Element

    The connectionPool element specifies a connection pool for the JDBC driver using the following parameters:
    1. The connectionUrl parameter specifies the JDBC driver-specific connection URL.
    2. The username parameter contains the user name used to connect via the connectionUrl.
    3. The driverClass parameter specifies the class name of the driver used to connect to the database.
    <infinispan
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
            xmlns="urn:infinispan:config:6.0">
            ...
    <persistence>
    	<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
               	            fetchPersistentState="false"
    			      ignoreModifications="false" 
    			      purgeOnStartup="false"
    			      key2StringMapper="org.infinispan.loaders.keymappers.DefaultTwoWayKey2StringMapper">
    		<connectionPool connectionUrl="jdbc:h2:mem:infinispan_binary_based;DB_CLOSE_DELAY=-1" 
    				username="sa" 
    				driverClass="org.h2.Driver"/>
    
    Copy to Clipboard Toggle word wrap
  3. The stringKeyedTable Element

    Add the stringKeyedTable element defines the table that stores cache entries. It uses the following parameters to configure the cache store:
    1. The dropOnExit parameter specifies whether the database tables are dropped upon shutdown.
    2. The createOnStart parameter specifies whether the database tables are created by the store on startup.
    3. The prefix parameter specifies a prefix string for the database table name.
    <infinispan
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
            xmlns="urn:infinispan:config:6.0">
            ...
    <persistence>
    	<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
    	                      fetchPersistentState="false"
    			      ignoreModifications="false" 
    			      purgeOnStartup="false"
    			      key2StringMapper="org.infinispan.loaders.keymappers.DefaultTwoWayKey2StringMapper">
    		<connectionPool connectionUrl="jdbc:h2:mem:infinispan_binary_based;DB_CLOSE_DELAY=-1" 
    				username="sa" 
    				driverClass="org.h2.Driver"/>
    		<stringKeyedTable dropOnExit="true"
    				  createOnStart="true"
    				  prefix="ISPN_STRING_TABLE">
    
    Copy to Clipboard Toggle word wrap
  4. The idColumn Element

    The idColumn element defines the column where the cache key or bucket ID is stored. It uses the following parameters:
    1. Use the name parameter to specify the name of the ID column.
    2. Use the type parameter to specify the type of the ID column.
    <infinispan
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
            xmlns="urn:infinispan:config:6.0">
            ...
    <persistence>
    	<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
    	                      fetchPersistentState="false"
    			      ignoreModifications="false" 
    			      purgeOnStartup="false"
    			      key2StringMapper="org.infinispan.loaders.keymappers.DefaultTwoWayKey2StringMapper">
    		<connectionPool connectionUrl="jdbc:h2:mem:infinispan_binary_based;DB_CLOSE_DELAY=-1" 
    				username="sa" 
    				driverClass="org.h2.Driver"/>
    		<stringKeyedTable dropOnExit="true"
    				  createOnStart="true"
    				  prefix="ISPN_STRING_TABLE">
    			<idColumn name="ID_COLUMN" 
    				  type="VARCHAR(255)" />
    
    Copy to Clipboard Toggle word wrap
  5. The dataColumn Element

    The dataColumn element specifies the column where the cache entry or bucket is stored.
    1. Use the name parameter to specify the name of the database column.
    2. Use the type parameter to specify the type of the database column.
    <infinispan
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
            xmlns="urn:infinispan:config:6.0">
            ...
    <persistence>
    	<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
    	                      fetchPersistentState="false"
    			      ignoreModifications="false" 
    			      purgeOnStartup="false"
    			      key2StringMapper="org.infinispan.loaders.keymappers.DefaultTwoWayKey2StringMapper">
    		<connectionPool connectionUrl="jdbc:h2:mem:infinispan_binary_based;DB_CLOSE_DELAY=-1" 
    				username="sa" 
    				driverClass="org.h2.Driver"/>
    		<stringKeyedTable dropOnExit="true"
    				  createOnStart="true"
    				  prefix="ISPN_STRING_TABLE">
    			<idColumn name="ID_COLUMN" 
    				  type="VARCHAR(255)" />
    			<dataColumn name="DATA_COLUMN" 
    				    type="BINARY" />
    
    Copy to Clipboard Toggle word wrap
  6. The timestampColumn Element

    The timestampColumn element specifies the column where the time stamp of the cache entry or bucket is stored.
    1. Use the name parameter to specify the name of the column used.
    2. Use the type parameter to specify the type of the column used.
    <infinispan
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
            xmlns="urn:infinispan:config:6.0">
            ...
    <persistence>
    	<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
    	                      fetchPersistentState="false"
    			      ignoreModifications="false" 
    			      purgeOnStartup="false"
    			      key2StringMapper="org.infinispan.loaders.keymappers.DefaultTwoWayKey2StringMapper">
    		<connectionPool connectionUrl="jdbc:h2:mem:infinispan_binary_based;DB_CLOSE_DELAY=-1" 
    				username="sa" 
    				driverClass="org.h2.Driver"/>
    		<stringKeyedTable dropOnExit="true"
    				  createOnStart="true" 
    				  prefix="ISPN_STRING_TABLE">
    			<idColumn name="ID_COLUMN" 
    				  type="VARCHAR(255)" />
    			<dataColumn name="DATA_COLUMN" 
    				    type="BINARY" />
    			<timestampColumn name="TIMESTAMP_COLUMN" 
    					 type="BIGINT" />
    		</stringKeyedTable>
    	</stringKeyedJdbcStore>
    </persistence>
    
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat