[id='segmented_cache_stores']
= Segmented Cache Stores
Cache stores can organize data into hash space segments to which keys map.

Segmented stores increase read performance for bulk operations; for example,
streaming over data (`Cache.size`, `Cache.entrySet.stream`), pre-loading the
cache, and doing state transfer operations.

However, segmented stores can also result in loss of performance for write
operations. This performance loss applies particularly to batch write
operations that can take place with transactions or write-behind stores. For
this reason, you should evaluate the overhead for write operations before you
enable segmented stores. The performance gain for bulk read operations might
not be acceptable if there is a significant performance loss for write
operations.

[IMPORTANT]
====
Loss of data can occur if the number of segments in a cache store are not
changed gracefully. For this reason, if you change the `numSegments` setting in the store configuration, you must migrate the existing store to use the new configuration.

The recommended method to migrate the cache store configuration is to perform a
rolling upgrade. The store migrator supports migrating a non-segmented cache
store to a segmented cache store only. The store migrator does not currently
support migrating from a segmented cache store.
====

[NOTE]
====
Not all cache stores support segmentation. See the appropriate section for each
store to determine if it supports segmentation.

If you plan to convert or write a new store to support segmentation, see the
following SPI section that provides more details.
====

.Reference

link:#key_ownership[Key Ownership]
