[id='configuring-file-stores_{context}']
= Configuring file-based cache stores
Add file-based cache stores to {brandname} to persist data on the host filesystem.

.Prerequisites

* Enable global state and configure a global persistent location if you are configuring embedded caches.

.Procedure

. Add the `persistence` element to your cache configuration.
. Optionally specify `true` as the value for the `passivation` attribute to write to the file-based cache store only when data is evicted from memory.
. Include the `file-store` element and configure attributes as appropriate.
. Specify `false` as the value for the `shared` attribute.
+
File-based cache stores should always be unique to each {brandname} instance.
If you want to use the same persistent across a cluster, configure shared storage such as a JDBC string-based cache store .
+
. Configure the `index` and `data` elements to specify the location where {brandname} creates indexes and stores data.
. Include the `write-behind` element if you want to configure the cache store with write-behind mode.

[discrete]
== File-based cache store configuration

.XML
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
include::xml/persistence_file_store.xml[]
----

.JSON
[source,json,options="nowrap",subs=attributes+,role="secondary"]
----
include::json/persistence_file_store.json[]
----

.YAML
[source,yaml,options="nowrap",subs=attributes+,role="secondary"]
----
include::yaml/persistence_file_store.yaml[]
----

.ConfigurationBuilder
[source,java,options="nowrap",subs=attributes+,role="secondary"]
----
include::code_examples/PersistenceFileStore.java[]
----
