= Persistence SPI Classes

The following notes apply to {brandname} persistence SPI classes:

link:{javadocroot}/org/infinispan/commons/io/ByteBuffer.html[ByteBuffer]:: Abstracts the serialized form of an object.

link:{javadocroot}/org/infinispan/persistence/spi/MarshallableEntry.html[MarshallableEntry]::
Abstracts the information held within a persistent store corresponding to a key/value added to the cache. Provides a method for reading this information both in serialized (link:{javadocroot}/org/infinispan/commons/io/ByteBuffer.html[ByteBuffer]) and deserialized (Object) format. Normally data read from the store is kept in serialized format and lazily deserialized on demand, within the link:{javadocroot}/org/infinispan/persistence/spi/MarshallableEntry.html[MarshallableEntry] implementation.

link:{javadocroot}/org/infinispan/persistence/spi/CacheWriter.html[CacheWriter] and link:{javadocroot}/org/infinispan/persistence/spi/CacheLoader.html[CacheLoader]::
Provide basic methods for writing to and reading from cache stores.

link:{javadocroot}/org/infinispan/persistence/spi/AdvancedCacheLoader.html[AdvancedCacheLoader] and link:{javadocroot}/org/infinispan/persistence/spi/AdvancedCacheWriter.html[AdvancedCacheWriter]::
Provide bulk operations to manipulate the underlaying storage, such as parallel
iteration and purging of expired entries, clear and size.

link:{javadocroot}/org/infinispan/persistence/spi/SegmentedAdvancedLoadWriteStore.html[SegmentedAdvancedLoadWriteStore]::
Provides all the operations that deal with segments.

Cache stores can be segmented if they do one of the following:

* Implement the
link:{javadocroot}/org/infinispan/persistence/spi/SegmentedAdvancedLoadWriteStore.html[SegmentedAdvancedLoadWriteStore] interface. In this case only a single
store instance is used per cache.

* Has a configuration that extends the link:{javadocroot}/org/infinispan/configuration/cache/AbstractSegmentedConfiguration.html[AbstractSegmentedConfiguration] abstract class.
+
This requires you to implement the `newConfigurationFrom()` method where it is expected that a new `StoreConfiguration` instance is created per invocation. This creates a store instance per segment to which a node can write. Stores might start and stop as data is moved between nodes.

A provider might choose to only implement a subset of these interfaces:

* Not implementing the  link:{javadocroot}/org/infinispan/persistence/spi/AdvancedCacheWriter.html[AdvancedCacheWriter] makes the given writer not usable for purging expired entries or clear

* If a loader does not implement the link:{javadocroot}/org/infinispan/persistence/spi/AdvancedCacheLoader.html[AdvancedCacheLoader] interface, then it will not participate in preloading nor in cache iteration (required also for stream operations).

//Community only
ifndef::productized[]

If you want to migrate your existing store to the new API or to write a new cache store implementation, the link:https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java[SingleFileStore] provides a good starting point.
endif::productized[]
