Package org.apache.ignite.cache.store
Interface CacheStoreSession
-
public interface CacheStoreSessionSession 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 sessionproperties()map. You can then commit this connection in theCacheStore.sessionEnd(boolean)method.CacheStoreSessioncan be injected into an implementation ofCacheStorewith@CacheStoreSessionResourceannotation.- See Also:
CacheStoreSessionResource
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> Tattach(@Nullable Object attachment)Attaches the given object to this session.<T> Tattachment()Retrieves the current attachment ornullif there is no attachment.StringcacheName()Cache name for the current store operation.booleanisWithinTransaction()Returnstrueif performing store operation within a transaction,falseotherwise.<K,V>
Map<K,V>properties()Gets current session properties.Transactiontransaction()Gets transaction spanning multiple store operations, ornullif there is no transaction.
-
-
-
Method Detail
-
transaction
Transaction transaction()
Gets transaction spanning multiple store operations, ornullif there is no transaction.- Returns:
- Transaction belonging to current session.
-
isWithinTransaction
boolean isWithinTransaction()
Returnstrueif performing store operation within a transaction,falseotherwise. Analogous to callingtransaction() != null.- Returns:
Trueif performing store operation within a transaction,falseotherwise.
-
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 useproperties()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 (ornullto discard current attachment).- Returns:
- Previously attached object, if any.
-
attachment
@Nullable <T> T attachment()
Retrieves the current attachment ornullif 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.
-
-