[[sifs_cache_store]]
==== Soft-Index File Store

The Soft-Index File Store is an experimental local file-based.
It is a pure Java implementation that tries to get
around Single File Store's drawbacks by implementing a variant of B+ tree that
is cached in-memory using Java's soft references - here's where the name
Soft-Index File Store comes from. This B+ tree (called Index) is offloaded on
filesystem to single file that does not need to be persisted - it is purged and
rebuilt when the cache store restarts, its purpose is only offloading.

The data that should be persisted are stored in a set of files that are written
in append-only way - that means that if you store this on conventional magnetic
disk, it does not have to seek when writing a burst of entries. It is not
stored in single file but set of files. When the usage of any of these files
drops below 50% (the entries from the file are overwritten to another file),
the file starts to be collected, moving the live entries into different file
and in the end removing that file from disk.

Most of the structures in Soft Index File Store are bounded, therefore you don't
have to be afraid of OOMEs. For example, you can configure the limits for
concurrently open files as well.

//Exclude segmentation support from productized docs.
ifndef::productized[]
===== Segmentation support
The Soft-Index file store supports segmentation and creates a separate
instance per segment. Segmentation results in multiple directories under the configured directory, where each directory is a number that represents the segment to which the data maps.
endif::productized[]

===== Configuration

Here is an example of Soft-Index File Store configuration via XML:

[source,xml]
----
<persistence>
    <soft-index-file-store xmlns="urn:infinispan:config:store:soft-index:8.0">
        <index path="/tmp/sifs/testCache/index" />
        <data path="/tmp/sifs/testCache/data" />
    </soft-index-file-store>
</persistence>
----

Programmatic configuration would look as follows:

[source,java]
----
ConfigurationBuilder b = new ConfigurationBuilder();
b.persistence()
    .addStore(SoftIndexFileStoreConfigurationBuilder.class)
        .indexLocation("/tmp/sifs/testCache/index");
        .dataLocation("/tmp/sifs/testCache/data")
----

===== Current limitations

Size of a node in the Index is limited, by default it is 4096 bytes, though it
can be configured. This size also limits the key length (or rather the length
of the serialized form): you can't use keys longer than size of the node
- 15 bytes. Moreover, the key length is stored as 'short', limiting it to 32767
bytes. There's no way how you can use longer keys - SIFS throws an exception
when the key is longer after serialization.

When entries are stored with expiration, SIFS cannot detect that some of those
entries are expired. Therefore, such old file will not be compacted (method
AdvancedStore.purgeExpired() is not implemented). This can lead to excessive
file-system space usage.

'''
