com.hazelcast.cache

## Interface CacheMergePolicy

- All Superinterfaces:
    Serializable
  All Known Subinterfaces:
    StorageTypeAwareCacheMergePolicy
  All Known Implementing Classes:
    HigherHitsCacheMergePolicy, LatestAccessCacheMergePolicy, PassThroughCacheMergePolicy, PutIfAbsentCacheMergePolicy

      public interface CacheMergePolicy
      extends Serializable

  Policy for merging cache entries after a split-brain has been healed.

  Passed `CacheEntryView` instances wrap the key and value as their original types with conversion to object from their storage types. If you don't need the original types of key and value, you should use `StorageTypeAwareCacheMergePolicy` which is a sub-type of this interface.

  See Also:
    `HigherHitsCacheMergePolicy`, `LatestAccessCacheMergePolicy`, `PassThroughCacheMergePolicy`, `PutIfAbsentCacheMergePolicy`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `merge(String cacheName, CacheEntryView mergingEntry, CacheEntryView existingEntry)` Selects one of the merging and existing cache entries to be merged.

- - ### Method Detail

    - #### merge

          Object merge(String cacheName,
                       CacheEntryView mergingEntry,
                       CacheEntryView existingEntry)

      Selects one of the merging and existing cache entries to be merged.

      Note that the `existingEntry` may be `null` if there is no entry with the same key in the destination cache. This happens, when the entry for that key was

      - only created in the smaller sub-cluster during the split-brain
      - removed in the larger sub-cluster during the split-brain
      Parameters:
        `cacheName` - name of the cache
        `mergingEntry` - `CacheEntryView` instance that has the cache entry to be merged
        `existingEntry` - `CacheEntryView` instance that has the existing cache entry or `null` if there is no existing cache entry
      Returns:
        the selected value for merging or `null` if the entry should be removed

Copyright © 2019. All rights reserved.