EntryEvent (Apache Geode 1.10.0)
Date: 2019-09-19

org.apache.geode.cache

## Interface EntryEvent<K,V>

- All Superinterfaces:
    CacheEvent<K,V>
  All Known Subinterfaces:
    TimestampedEntryEvent

      public interface EntryEvent<K,V>
      extends CacheEvent<K,V>

  Contains information about an event affecting an entry, including its identity and the the circumstances of the event. It is passed in to `CacheListener`, `CapacityController`, and `CacheWriter`.

  If this event originated from a region stored off heap then this event can only be used as long as the notification method that obtained it has not returned. For example in your implementation of `CacheListener.afterUpdate(EntryEvent)` the event parameter is only valid until your afterUpdate method returns. It is not safe to store instances of this class and use them later when using off heap storage. Attempts to access off-heap data from this event after it has expired will result in an IllegalStateException.

  Since:
    GemFire 3.0
  See Also:
    `CacheListener`, `CacheWriter`, `RegionEvent`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `K` | `getKey()` Returns the key.
    `V` | `getNewValue()` Returns the value in the cache after this event.
    `V` | `getOldValue()` Returns the value in the cache prior to this event.
    `SerializedCacheValue<V>` | `getSerializedNewValue()` Returns the serialized form of the value in the cache after this event.
    `SerializedCacheValue<V>` | `getSerializedOldValue()` Returns the serialized form of the value in the cache before this event.
    `TransactionId` | `getTransactionId()` Gets the TransactionId for this EntryEvent.
    `boolean` | `hasClientOrigin()` Returns true if this event originated on a client.
    `boolean` | `isOldValueAvailable()` Returns `true` if the old value is "available".

    - ### Methods inherited from interface org.apache.geode.cache.CacheEvent

      `getCallbackArgument, getDistributedMember, getOperation, getRegion, isCallbackArgumentAvailable, isOriginRemote`

- - ### Method Detail

    - #### getKey

          K getKey()

      Returns the key.
      Returns:
        the key

    - #### getOldValue

          V getOldValue()

      Returns the value in the cache prior to this event. When passed to an event handler after an event occurs, this value reflects the value that was in the cache in this VM, not necessarily the value that was in the cache VM that initiated the operation. In certain scenarios the old value may no longer be available in which case `null` is returned. This can happen for disk regions when the old value is on disk only.
      Returns:
        the old value in the cache prior to this event. If the entry did not exist, was invalid, or was not available, then null is returned.
      Throws:
        `IllegalStateException` - if off-heap and called after the method that was passed this EntryEvent returns.

    - #### getSerializedOldValue

          SerializedCacheValue<V> getSerializedOldValue()

      Returns the serialized form of the value in the cache before this event.
      Returns:
        the serialized form of the value in the cache before this event
      Throws:
        `IllegalStateException` - if off-heap and called after the method that was passed this EntryEvent returns.
      Since:
        GemFire 5.5

    - #### getNewValue

          V getNewValue()

      Returns the value in the cache after this event.
      Returns:
        the value in the cache after this event
      Throws:
        `IllegalStateException` - if off-heap and called after the method that was passed this EntryEvent returns.

    - #### getSerializedNewValue

          SerializedCacheValue<V> getSerializedNewValue()

      Returns the serialized form of the value in the cache after this event.
      Returns:
        the serialized form of the value in the cache after this event
      Throws:
        `IllegalStateException` - if off-heap and called after the method that was passed this EntryEvent returns.
      Since:
        GemFire 5.5

    - #### getTransactionId

          TransactionId getTransactionId()

      Gets the TransactionId for this EntryEvent.
      Returns:
        the ID of the transaction that performed the operation that generated this event; null if no transaction involved.
      Since:
        GemFire 4.0

    - #### hasClientOrigin

          boolean hasClientOrigin()

      Returns true if this event originated on a client.
      Returns:
        true if this event originated on a client.
      Since:
        GemFire 5.7

    - #### isOldValueAvailable

          boolean isOldValueAvailable()

      Returns `true` if the old value is "available". Not available means that an old value existed but it could not be obtained or it was deemed too expensive to obtain. Note that `getOldValue()` will return `null` when this method returns `false`.
      Since:
        GemFire 6.0