[id='sfs_cache_store']
= Single File Cache Stores
Single File cache stores, `SingleFileStore`, persist data to a single file and maintains an in-memory index of keys and their values in that file.

Because `SingleFileStore` keeps an in-memory index of keys and the location of
values, it requires additional memory, depending on the key size and the number
of keys. For this reason, `SingleFileStore` is not recommended for use cases
where the keys have a large size.

In some cases, `SingleFileStore` can also become fragmented. If the size of
values continually increases, available space in the single file is not used 
but the entry is appended to the end of the file. Available space in the file
is used only if an entry can fit within it. Likewise, if you remove all entries
from memory, the single file store does not decrease in size or become
defragmented.

.Declarative configuration

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

.Programmatic configuration

[source,java,options=nowrap]
----
include::code_examples/ConfigSingleFileStore.java[]
----

.Segmentation

Single File cache stores support segmentation and create a separate
instance per segment, which results in multiple directories in the path you
configure. Each directory is a number that represents the segment to which the
data maps.

.Reference

* link:{configdocroot}infinispan-config-{schemaversion}.html[{brandname} configuration schema]
link:{javadocroot}/org/infinispan/persistence/file/SingleFileStore.html[SingleFileStore]
