[id='shared-cache-stores_{context}']
= Shared cache stores

{brandname} cache stores can be local to a given node or shared across all nodes in the cluster.
By default, cache stores are local (`shared="false"`).

* Local cache stores are unique to each node; for example, a file-based cache store that persists data to the host filesystem.
+
Local cache stores can fetch state and purge on startup to avoid loading stale entries from persistent storage.

* Shared cache stores allow multiple nodes to use the same persistent storage; for example, a JDBC cache store that allows multiple nodes to access the same database.
+
Shared cache stores ensure that only the primary owner write to persistent storage, instead of backup nodes performing write operations for every modification.

[IMPORTANT]
====
Never configure shared cache stores to fetch state and purge on startup.
Fetching state with shared cache stores results in performance issues and longer cluster start times.
Purging deletes data, which is not typically the desired behavior for persistent storage.
====

.Local cache store
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
<persistence>
  <store shared="false"
         fetch-state="true"
         purge="true"/>
</persistence>
----

.Shared cache store
[source,xml,options="nowrap",subs=attributes+,role="secondary"]
----
<persistence>
  <store shared="true"
         fetch-state="false"
         purge="false"/>
</persistence>
----

[role="_additional-resources"]
.Additional resources
* link:{configdocroot}[{brandname} Configuration Schema]
