Ce contenu n'est pas disponible dans la langue sélectionnée.
17.2. Cache Store Configuration
17.2.1. Configuring the Cache Store Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Cache stores can be configured in a chain. Cache read operations checks each cache store in the order configured until a valid non-null element of data has been located. Write operations affect all cache stores unless the
ignoreModifications element has been set to "true" for a specific cache store.
17.2.2. Configure the Cache Store using XML (Library Mode) Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
The following example demonstrates cache store configuration using XML in JBoss Data Grid's Library mode:
For details about the elements and parameters used in this sample configuration, see Section 18.2, “Cache Store Configuration Details (Library Mode)”.
17.2.3. Configure the Cache Store Programmatically Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
The following example demonstrates how to configure the cache store programmatically:
Note
This configuration is for a single-file cache store. Some attributes, such as
location are specific to the single-file cache store and are not used for other types of cache stores.
Procedure 17.1. Configure the Cache store Programatically
- Use the
ConfigurationBuilderto create a new configuration object. - The
passivationelements affects the way Red Hat JBoss Data Grid interacts with stores. Passivation removes an object from an in-memory cache and writes it to a secondary data store, such as a system or database. If no secondary data store exists, then the object will only be removed from the in-memory cache. Passivation isfalseby default. - The
addSingleFileStore()elements adds the SingleFileStore as the cache store for this configuration. It is possible to create other stores, such as a JDBC Cache Store, which can be added using theaddStoremethod. - The
sharedparameter indicates that the cache store is shared by different cache instances. For example, where all instances in a cluster use the same JDBC settings to talk to the same remote, shared database.sharedisfalseby default. When set totrue, it prevents duplicate data being written to the cache store by different cache instances. - The
preloadelement is set tofalseby default. When set totruethe data stored in the cache store is preloaded into the memory when the cache starts. This allows data in the cache store to be available immediately after startup and avoids cache operations delays as a result of loading data lazily. Preloaded data is only stored locally on the node, and there is no replication or distribution of the preloaded data. JBoss Data Grid will only preload up to the maximum configured number of entries in eviction. - The
fetchPersistentStateelement determines 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 store has this property set totrue. ThefetchPersistentStateproperty isfalseby default. - The
ignoreModificationselement determines whether write methods are pushed to the specific cache store by allowing write operations to the local file cache store, but not the shared cache store. In some cases, transient application data should only reside in a file-based cache store on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache store used by all servers in the network.ignoreModificationsisfalseby default. - The
purgeOnStartupelement controls whether cache store is purged when it starts up and isfalseby default. - The
locationelement configuration element sets a location on disk where the store can write. - These attributes configure aspects specific to each cache store. For example, the
locationattribute points to where the SingleFileStore will keep files containing data. Other stores may require more complex configuration. - The
singletonelement enables modifications to be stored by only one node in the cluster. This node is called the coordinator. The coordinator pushes the caches in-memory states to disk. This function is activated by setting theenabledattribute totruein all nodes. Thesharedparameter cannot be defined withsingletonenabled at the same time. Theenabledattribute isfalseby default. - The
pushStateWhenCoordinatorelement is set totrueby default. Iftrue, this property will cause a node that has become the coordinator to transfer in-memory state to the underlying cache store. This parameter is useful where the coordinator has crashed and a new coordinator is elected.
17.2.4. About SKIP_CACHE_LOAD Flag Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
In Red Hat JBoss Data Grid's Remote Client-Server mode, when the cache is preloaded from a cache store and eviction is disabled, read requests go to the memory. If the entry is not found in a memory during a read request, it accesses the cache store which may impact the read performance.
To avoid referring to the cache store when a key is not found in the memory, use the
SKIP_CACHE_LOAD flag.
17.2.5. About the SKIP_CACHE_STORE Flag Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
When the
SKIP_CACHE_STORE Flag is used then the cache store will not be considered for the specified cache operations. This flag can be useful to place an entry in the cache without having it included in the configured cache store, along with determining if an entry is found within a cache without retrieving it from the associated cache store.
17.2.6. About the SKIP_SHARED_CACHE_STORE Flag Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
When the
SKIP_SHARED_CACHE_STORE Flag is enabled then any shared cache store will not be considered for the specified cache operations. This flag can be useful to place an entry in the cache without having it included in the shared cache store, along with determining if an entry is found within a cache without retrieving it from the shared cache store.