K
- Cache key type.V
- Cache value type.public interface GridCache<K,V> extends org.apache.ignite.internal.processors.cache.CacheProjection<K,V>
org.apache.ignite.Ignite#cache(String)
method.
CacheProjection
API which contains vast majority of cache functionality
and documentation. In addition to CacheProjection
functionality this API provides:
'loadCache(..)'
methods to load cache either synchronously or asynchronously.
These methods don't specify any keys to load, and leave it to the underlying storage to load cache
data based on the optionally passed in arguments.
affinity()
provides CacheAffinityFunction
service for information on
data partitioning and mapping keys to grid nodes responsible for caching those keys.
'tx{Un}Synchronize(..)'
witch allow to get notifications for transaction state changes.
This feature is very useful when integrating cache transactions with some other in-house transactions.
metrics()
to provide metrics for the whole cache.configuration()
to provide cache configuration bean.Modifier and Type | Method and Description |
---|---|
CacheAffinity<K> |
affinity()
Gets affinity service to provide information about data partitioning
and distribution.
|
CacheConfiguration |
configuration()
Gets configuration bean for this cache.
|
org.apache.ignite.internal.IgniteInternalFuture<?> |
forceRepartition()
Forces this cache node to re-balance its partitions.
|
CacheMetrics |
metrics()
Gets metrics (statistics) for this cache.
|
CacheMetricsMXBean |
mxBean()
Gets metrics (statistics) for this cache.
|
long |
offHeapAllocatedSize()
Gets memory size allocated in off-heap.
|
long |
offHeapEntriesCount()
Gets number of cache entries stored in off-heap memory.
|
Iterator<Map.Entry<K,V>> |
offHeapIterator()
Gets iterator over keys and values belonging to this cache off-heap memory on local node.
|
long |
overflowSize()
Gets size (in bytes) of all entries swapped to disk.
|
javax.cache.Cache.Entry<K,V> |
randomEntry()
Gets a random entry out of cache.
|
Iterator<Map.Entry<K,V>> |
swapIterator()
Gets iterator over keys and values belonging to this cache swap space on local node.
|
long |
swapKeys()
Gets number of swap entries (keys).
|
long |
swapSize()
Gets size in bytes for swap space.
|
Collection<TransactionSynchronization> |
txSynchronizations()
Gets registered transaction synchronizations.
|
void |
txSynchronize(TransactionSynchronization syncs)
Registers transactions synchronizations for all transactions started by this cache.
|
void |
txUnsynchronize(TransactionSynchronization syncs)
Removes transaction synchronizations.
|
cache, clear, clear, clear, clearAll, clearAsync, clearAsync, clearAsync, clearLocally, clearLocally, clearLocallyAll, containsKey, containsKeyAsync, containsKeys, containsKeysAsync, containsValue, entry, entrySet, entrySet, evict, evictAll, evictAll, flags, flagsOff, flagsOn, get, getAll, getAllAsync, getAsync, globalPrimarySize, globalSize, gridProjection, isEmpty, isLocked, isLockedByThread, keepPortable, keySet, keySet, localEntries, localPeek, localRemoveAll, localSize, lock, lockAll, lockAllAsync, lockAsync, name, nearSize, peek, peek, primaryEntrySet, primaryKeySet, primarySize, primaryValues, projection, projection, promote, promoteAll, put, putAll, putAllAsync, putAsync, putIfAbsent, putIfAbsentAsync, putx, putxAsync, putxIfAbsent, putxIfAbsentAsync, queries, reload, reloadAsync, remove, remove, removeAll, removeAll, removeAllAsync, removeAllAsync, removeAsync, removeAsync, removex, removexAsync, replace, replace, replaceAsync, replaceAsync, replacex, replacexAsync, size, size, sizeAsync, toMap, tx, txStart, txStart, txStart, txStartEx, unlock, unlockAll, values
CacheConfiguration configuration()
void txSynchronize(@Nullable TransactionSynchronization syncs)
syncs
- Transaction synchronizations to register.void txUnsynchronize(@Nullable TransactionSynchronization syncs)
syncs
- Transactions synchronizations to remove.txSynchronize(TransactionSynchronization)
Collection<TransactionSynchronization> txSynchronizations()
txSynchronize(TransactionSynchronization)
CacheAffinity<K> affinity()
CacheMetrics metrics()
CacheMetricsMXBean mxBean()
long overflowSize() throws IgniteCheckedException
IgniteCheckedException
- In case of error.long offHeapEntriesCount()
long offHeapAllocatedSize()
long swapSize() throws IgniteCheckedException
IgniteCheckedException
- If failed.long swapKeys() throws IgniteCheckedException
IgniteCheckedException
- If failed.Iterator<Map.Entry<K,V>> swapIterator() throws IgniteCheckedException
Returned iterator supports remove
operation which delegates to
#removex(Object, org.apache.ignite.lang.IgnitePredicate[])
method.
CacheFlag.SKIP_SWAP
.IgniteCheckedException
- If failed.CacheProjection.promote(Object)
Iterator<Map.Entry<K,V>> offHeapIterator() throws IgniteCheckedException
Returned iterator supports remove
operation which delegates to
#removex(Object, org.apache.ignite.lang.IgnitePredicate[])
method.
IgniteCheckedException
- If failed.@Nullable javax.cache.Cache.Entry<K,V> randomEntry()
O(S * N/64)where
N
is the size of internal hash
table and S
is the number of hash table buckets to sample, which is 5
by default. However, if the table is pretty dense, with density factor of N/64
,
which is true for near fully populated caches, this method will generally perform significantly
faster with complexity of O(S) where S = 5
.
Note that this method is not available on CacheProjection
API since it is
impossible (or very hard) to deterministically return a number value when pre-filtering
and post-filtering is involved (e.g. projection level predicate filters).
null
if cache is empty.org.apache.ignite.internal.IgniteInternalFuture<?> forceRepartition()
CacheConfiguration.getRebalanceDelay()
configuration parameter has non-zero value.
When many nodes are started or stopped almost concurrently, it is more efficient to delay
rebalancing until the node topology is stable to make sure that no redundant re-partitioning
happens.
In case ofCacheMode.PARTITIONED
caches, for better efficiency user should
usually make sure that new nodes get placed on the same place of consistent hash ring as
the left nodes, and that nodes are restarted before
rebalanceDelay
expires. To place nodes
on the same place in consistent hash ring, use
CacheRendezvousAffinityFunction.setHashIdResolver(CacheAffinityNodeHashResolver)
to make sure that
a node maps to the same hash ID if re-started.
See CacheConfiguration.getRebalanceDelay()
for more information on how to configure
rebalance re-partition delay.
Follow @ApacheIgnite
Apache Ignite Fabric : ver. 1.0.0-RC3 Release Date : March 24 2015