Este conteúdo não está disponível no idioma selecionado.
18.6. JDBC Based Cache Stores
JdbcBinaryStore.JdbcStringBasedStore.JdbcMixedStore.
18.6.1. JdbcBinaryStores Copiar o linkLink copiado para a área de transferência!
JdbcBinaryStore supports all key types. It stores all keys with the same hash value (hashCode method on the key) in the same table row/blob. The hash value common to the included keys is set as the primary key for the table row/blob. As a result of this hash value, JdbcBinaryStore offers excellent flexibility but at the cost of concurrency and throughput.
k1, k2 and k3) have the same hash code, they are stored in the same table row. If three different threads attempt to concurrently update k1, k2 and k3, they must do it sequentially because all three keys share the same row and therefore cannot be simultaneously updated.
18.6.1.1. JdbcBinaryStore Configuration (Remote Client-Server Mode) Copiar o linkLink copiado para a área de transferência!
JdbcBinaryStore using Red Hat JBoss Data Grid's Remote Client-Server mode with Passivation enabled:
18.6.1.2. JdbcBinaryStore Configuration (Library Mode) Copiar o linkLink copiado para a área de transferência!
JdbcBinaryStore:
18.6.1.3. JdbcBinaryStore Programmatic Configuration Copiar o linkLink copiado para a área de transferência!
JdbcBinaryStore:
Procedure 18.4. JdbcBinaryStore Programmatic Configuration (Library Mode)
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.Add the
JdbcBinaryStoreConfigurationBuilderAdd theJdbcBinaryStoreconfiguration builder to build a specific configuration related to this store.Set Up Persistence
fetchPersistentStatedetermines whether or not to fetch the persistent state of a cache and apply it to the local cache store when joining the cluster. If the cache store is shared the fetch persistent state is ignored, as caches access the same cache store. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set totrue. ThefetchPersistentStateproperty isfalseby default.Set Modifications
ignoreModificationsdetermines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network.ignoreModificationsisfalseby default.Configure Purging
purgeOnStartupspecifies whether the cache is purged when initially started.Configure the Table
Configure the table as follows:dropOnExitdetermines if the table will be dropped when the cache store is stopped. This is set tofalseby default.createOnStartcreates the table when starting the cache store if no table currently exists. This method istrueby default.tableNamePrefixsets the prefix for the name of the table in which the data will be stored.- The
idColumnNameproperty defines the column where the cache key or bucket ID is stored. - The
dataColumnNameproperty specifies the column where the cache entry or bucket is stored. - The
timestampColumnNameelement specifies the column where the time stamp of the cache entry or bucket is stored.
The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the user name used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Note
18.6.2. JdbcStringBasedStores Copiar o linkLink copiado para a área de transferência!
JdbcStringBasedStore stores each entry in its own row in the table, instead of grouping multiple entries into each row, resulting in increased throughput under a concurrent load. It also uses a (pluggable) bijection that maps each key to a String object. The Key2StringMapper interface defines the bijection.
DefaultTwoWayKey2StringMapper that handles primitive types.
18.6.2.1. JdbcStringBasedStore Configuration (Remote Client-Server Mode) Copiar o linkLink copiado para a área de transferência!
JdbcStringBasedStore for Red Hat JBoss Data Grid's Remote Client-Server mode:
18.6.2.2. JdbcStringBasedStore Configuration (Library Mode) Copiar o linkLink copiado para a área de transferência!
JdbcStringBasedStore:
18.6.2.3. JdbcStringBasedStore Multiple Node Configuration (Remote Client-Server Mode) Copiar o linkLink copiado para a área de transferência!
JdbcStringBasedStore in Red Hat JBoss Data Grid's Remote Client-Server mode. This configuration is used when multiple nodes must be used.
18.6.2.4. JdbcStringBasedStore Programmatic Configuration Copiar o linkLink copiado para a área de transferência!
JdbcStringBasedStore:
Procedure 18.5. Configure the JdbcStringBasedStore Programmatically
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.Add
JdbcStringBasedStoreConfigurationBuilderAdd theJdbcStringBasedStoreconfiguration builder to build a specific configuration related to this store.Set Up Persistence
fetchPersistentStatedetermines whether or not to fetch the persistent state of a cache and apply it to the local cache store when joining the cluster. If the cache store is shared the fetch persistent state is ignored, as caches access the same cache store. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set totrue. ThefetchPersistentStateproperty isfalseby default.Set Modifications
ignoreModificationsdetermines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network.ignoreModificationsisfalseby default.Configure Purging
purgeOnStartupspecifies whether the cache is purged when initially started.Configure the Table
dropOnExitdetermines if the table will be dropped when the cache store is stopped. This is set tofalseby default.createOnStartcreates the table when starting the cache store if no table currently exists. This method istrueby default.tableNamePrefixsets the prefix for the name of the table in which the data will be stored.idColumnNameTheidColumnNameproperty defines the column where the cache key or bucket ID is stored.dataColumnNameThedataColumnNameproperty specifies the column where the cache entry or bucket is stored.timestampColumnNameThetimestampColumnNameelement specifies the column where the time stamp of the cache entry or bucket is stored.
The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the username used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Note
18.6.3. JdbcMixedStores Copiar o linkLink copiado para a área de transferência!
JdbcMixedStore is a hybrid implementation that delegates keys based on their type to either the JdbcBinaryStore or JdbcStringBasedStore.
18.6.3.1. JdbcMixedStore Configuration (Remote Client-Server Mode) Copiar o linkLink copiado para a área de transferência!
JdbcMixedStore for Red Hat JBoss Data Grid's Remote Client-Server mode:
18.6.3.2. JdbcMixedStore Configuration (Library Mode) Copiar o linkLink copiado para a área de transferência!
mixedKeyedJdbcStore:
18.6.3.3. JdbcMixedStore Programmatic Configuration Copiar o linkLink copiado para a área de transferência!
JdbcMixedStore:
Procedure 18.6. Configure JdbcMixedStore Programmatically
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.Add
JdbcMixedStoreConfigurationBuilderAdd theJdbcMixedStoreconfiguration builder to build a specific configuration related to this store.Set Up Persistence
fetchPersistentStatedetermines whether or not to fetch the persistent state of a cache and apply it to the local cache store when joining the cluster. If the cache store is shared the state is ignored, as caches access the same cache store. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set totrue. ThefetchPersistentStateproperty isfalseby default.Set Modifications
ignoreModificationsdetermines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network.ignoreModificationsisfalseby default.Configure Purging
purgeOnStartupspecifies whether the cache is purged when initially started.Configure the Table
Configure the table as follows:dropOnExitdetermines if the table will be dropped when the cache store is stopped. This is set tofalseby default.createOnStartcreates the table when starting the cache store if no table currently exists. This method istrueby default.tableNamePrefixsets the prefix for the name of the table in which the data will be stored.- The
idColumnNameproperty defines the column where the cache key or bucket ID is stored. - The
dataColumnNameproperty specifies the column where the cache entry or bucket is stored. - The
timestampColumnNameelement specifies the column where the time stamp of the cache entry or bucket is stored.
The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the username used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Note
18.6.4. Cache Store Troubleshooting Copiar o linkLink copiado para a área de transferência!
18.6.4.1. IOExceptions with JdbcStringBasedStore Copiar o linkLink copiado para a área de transferência!
JdbcStringBasedStore indicates that your data column type is set to VARCHAR, CLOB or something similar instead of the correct type, BLOB or VARBINARY. Despite its name, JdbcStringBasedStore only requires that the keys are strings while the values can be any data type, so that they can be stored in a binary column.