org.apache.ignite.cache.store

## Interface CacheStoreSession

-     public interface CacheStoreSession

  Session for the cache store operations. The main purpose of cache store session is to hold context between multiple store invocations whenever in transaction. For example, if using JDBC, you can store the ongoing database connection in the session `properties()` map. You can then commit this connection in the `CacheStore.sessionEnd(boolean)` method.

  `CacheStoreSession` can be injected into an implementation of `CacheStore` with `@CacheStoreSessionResource` annotation.

  See Also:
    `CacheStoreSessionResource`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> T` | `attach(@Nullable Object attachment)` Attaches the given object to this session.
    `<T> T` | `attachment()` Retrieves the current attachment or `null` if there is no attachment.
    `String` | `cacheName()` Cache name for the current store operation.
    `boolean` | `isWithinTransaction()` Returns `true` if performing store operation within a transaction, `false` otherwise.
    `<K,V> Map<K,V>` | `properties()` Gets current session properties.
    `Transaction` | `transaction()` Gets transaction spanning multiple store operations, or `null` if there is no transaction.

- - ### Method Detail

    - #### transaction

          Transaction transaction()

      Gets transaction spanning multiple store operations, or `null` if there is no transaction.
      Returns:
        Transaction belonging to current session.

    - #### isWithinTransaction

          boolean isWithinTransaction()

      Returns `true` if performing store operation within a transaction, `false` otherwise. Analogous to calling `transaction() != null`.
      Returns:
        `True` if performing store operation within a transaction, `false` otherwise.

    - #### attach

          @Nullable
          <T> T attach(@Nullable
                                 @Nullable Object attachment)

      Attaches the given object to this session.

      An attached object may later be retrieved via the `attachment()` method. Invoking this method causes any previous attachment to be discarded. To attach additional objects use `properties()` map.

      The current attachment may be discarded by attaching `null`.

      Type Parameters:
        `T` - Type of the previously attached object.
      Parameters:
        `attachment` - The object to be attached (or `null` to discard current attachment).
      Returns:
        Previously attached object, if any.

    - #### attachment

          @Nullable
          <T> T attachment()

      Retrieves the current attachment or `null` if there is no attachment.
      Type Parameters:
        `T` - Type of the attached object.
      Returns:
        Currently attached object, if any.

    - #### properties

          <K,V> Map<K,V> properties()

      Gets current session properties. You can add properties directly to the returned map.
      Type Parameters:
        `K` - Type of keys in the properties map.
        `V` - Type of mapped values in the properties map.
      Returns:
        Current session properties.

    - #### cacheName

          String cacheName()

      Cache name for the current store operation. Note that if the same store is reused between different caches, then the cache name will change between different store operations.
      Returns:
        Cache name for the current store operation.

${current.year} Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.16.0
Release Date | : December 15 2023