Chapter 20. Cache Writing Modes
- Write-Through (Synchronous)
- Write-Behind (Asynchronous)
20.1. Write-Through Caching
Cache.put() invocation), the call does not return until JBoss Data Grid has located and updated the underlying cache store. This feature allows updates to the cache store to be concluded within the client thread boundaries.
20.1.1. Write-Through Caching Benefits and Disadvantages
The primary advantage of the Write-Through mode is that the cache and cache store are updated simultaneously, which ensures that the cache store remains consistent with the cache contents.
Due to the cache store being updated simultaneously with the cache entry, there is a possibility of reduced performance for cache operations that occur concurrently with the cache store accesses and updates.
20.1.2. Write-Through Caching Configuration (Library Mode)
Procedure 20.1. Configure a Write-Through Local File Cache Store
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:infinispan:config:6.2">
<global />
<default />
<namedCache name="persistentCache">
<persistence>
<singleFile fetchPersistentState="true"
ignoreModifications="false"
purgeOnStartup="false"
shared="false"
location="${java.io.tmpdir}"/>
</persistence>
</namedCache>
</infinispan>- The
nameparameter specifies the name of thenamedCacheto use. - The
fetchPersistentStateparameter determines whether the persistent state is fetched when joining a cluster. Set this totrueif 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 totrue. ThefetchPersistentStateparameter isfalseby default. - The
ignoreModificationsparameter 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. - The
purgeOnStartupparameter specifies whether the cache is purged when initially started. - The
sharedparameter is used when multiple cache instances share a cache store and is now defined at the cache store level. This parameter can be set to prevent multiple cache instances writing the same modification multiple times. Valid values for this parameter aretrueandfalse.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.