org.apache.ignite.internal.processors.cache.distributed.near

## Class GridNearCacheAdapter<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheAdapter<K,V>
  - - org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter<K,V>
    - - org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter<K,V>

All Implemented Interfaces:
  Externalizable, Serializable, Iterable<javax.cache.Cache.Entry<K,V>>, CacheProjection<K,V>, GridCache<K,V>, GridCacheProjectionEx<K,V>

Direct Known Subclasses:
  GridNearAtomicCache, GridNearTransactionalCache

    public abstract class GridNearCacheAdapter<K,V>
    extends GridDistributedCacheAdapter<K,V>

Common logic for near caches.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter

`GridCacheAdapter.AsyncOp<T>, GridCacheAdapter.CacheExpiryPolicy, GridCacheAdapter.FutureHolder, GridCacheAdapter.UpdateGetTimeStatClosure<T>, GridCacheAdapter.UpdatePutAndGetTimeStatClosure<T>, GridCacheAdapter.UpdatePutTimeStatClosure<T>, GridCacheAdapter.UpdateRemoveTimeStatClosure<T>, GridCacheAdapter.UpdateTimeStatClosure<T>`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter

`cacheCfg, CLEAR_ALL_SPLIT_THRESHOLD, ctx, gridCfg, keyCheck, lastFut, locNodeId, log, map, metrics, mxBean, RET2NULL`

### Constructor Summary

Constructors
`protected` `GridNearCacheAdapter()` Empty constructor required for `Externalizable`.
`protected` `GridNearCacheAdapter(GridCacheContext<K,V> ctx)`

### Method Summary

Methods
`void` `clearLocally0(Collection<? extends K> keys, CacheEntryPredicate[] filter)`
`boolean` `clearLocally0(K key, CacheEntryPredicate[] filter)`
`abstract GridDhtCacheAdapter<K,V>` `dht()`
`javax.cache.Cache.Entry<K,V>` `entry(K key)` Gets entry from cache with the specified key.
`GridCacheEntryEx` `entryEx(KeyCacheObject key, AffinityTopologyVersion topVer)`
`GridCacheEntryEx` `entryEx(KeyCacheObject key, boolean touch)`
`GridNearCacheEntry` `entryExx(KeyCacheObject key, AffinityTopologyVersion topVer)`
`Set<javax.cache.Cache.Entry<K,V>>` `entrySet(CacheEntryPredicate... filter)`
`Set<javax.cache.Cache.Entry<K,V>>` `entrySet(int part)` Gets set containing cache entries that belong to provided partition or `null` if partition is not found locally.
`boolean` `evict(K key, CacheEntryPredicate[] filter)`
`void` `evictAll(Collection<? extends K> keys, CacheEntryPredicate[] filter)`
`boolean` `evictNearOnly(K key, CacheEntryPredicate[] filter)`
`long` `igfsDataSpaceMax()` Get maximum space available for IGFS.
`long` `igfsDataSpaceUsed()` Get current amount of used IGFS space in bytes.
`protected void` `init()` Post constructor initialization for subclasses.
`boolean` `isAllLockedNearOnly(Iterable<? extends K> keys)`
`boolean` `isIgfsDataCache()` Checks whether this cache is IGFS data cache.
`boolean` `isLocked(K key)` Checks if any node owns a lock for this key.
`boolean` `isLockedNearOnly(K key)`
`boolean` `isMongoDataCache()` Checks whether this cache is Mongo data cache.
`boolean` `isMongoMetaCache()` Checks whether this cache is Mongo meta cache.
`boolean` `isNear()`
`Set<K>` `keySet(CacheEntryPredicate[] filter)` Set of keys cached on this node.
`IgniteInternalFuture<Map<K,V>>` `loadAsync(IgniteInternalTx tx, Collection<KeyCacheObject> keys, boolean reload, boolean forcePrimary, UUID subjId, String taskName, boolean deserializePortable, javax.cache.expiry.ExpiryPolicy expiryPlc, boolean skipVal)`
`void` `localLoad(Collection<? extends K> keys, javax.cache.expiry.ExpiryPolicy plc)`
`void` `localLoadCache(IgniteBiPredicate<K,V> p, Object[] args)` Delegates to `CacheStore.loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)` method to load state from the underlying persistent storage.
`IgniteInternalFuture<?>` `localLoadCacheAsync(IgniteBiPredicate<K,V> p, Object[] args)` Asynchronously delegates to `CacheStore.loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)` method to reload state from the underlying persistent storage.
`Set<javax.cache.Cache.Entry<K,V>>` `nearEntries()`
`Iterator<javax.cache.Cache.Entry<K,V>>` `nearEntriesIterator()`
`Set<K>` `nearKeySet(CacheEntryPredicate filter)`
`int` `nearSize()` Gets size of near cache key set.
`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.
`void` `onIgfsDataSizeChanged(long delta)` Callback invoked when data is added to IGFS cache.
`V` `peek(K key, CacheEntryPredicate filter)`
`V` `peek(K key, Collection<GridCachePeekMode> modes)` Peeks at cached value using optional set of peek modes.
`GridNearCacheEntry` `peekExx(KeyCacheObject key)`
`V` `peekNearOnly(K key)` Peeks only near cache without looking into DHT cache.
`GridCachePreloader<K,V>` `preloader()`
`Set<javax.cache.Cache.Entry<K,V>>` `primaryEntrySet(CacheEntryPredicate... filter)`
`Set<K>` `primaryKeySet(CacheEntryPredicate... filter)`
`int` `primarySize()` Gets the number of all primary entries cached on this node.
`Collection<V>` `primaryValues(CacheEntryPredicate... filter)`
`protected void` `processGetResponse(UUID nodeId, GridNearGetResponse res)`
`V` `promote(K key)` This method promotes cache entry by given key, if any, from offheap or swap storage into memory.
`V` `promote(K key, boolean deserializePortable)`
`void` `promoteAll(Collection<? extends K> keys)` This method unswaps cache entries by given keys, if any, from swap storage into memory.
`javax.cache.Cache.Entry<K,V>` `randomEntry()` Gets a random entry out of cache.
`IgniteInternalFuture<Object>` `readThroughAllAsync(Collection<KeyCacheObject> keys, boolean reload, boolean skipVals, IgniteInternalTx tx, UUID subjId, String taskName, IgniteBiInClosure<KeyCacheObject,Object> vis)`
`V` `reload(K key)` Reloads a single key from persistent storage.
`int` `size()` Gets the number of all entries cached on this node.
`List<GridCacheClearAllRunnable<K,V>>` `splitClearLocally()` Split clearLocally all task into multiple runnables.
`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.
`String` `toString()`
`Collection<V>` `values(CacheEntryPredicate... filter)` Collection of values cached on this node.

### Methods inherited from class org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter

`lockAllAsync, lockAllAsync, removeAll, removeAllAsync, removeVersionedEntry, txLockAsync`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter

`affinity, affinityNode, allEntries, asyncOp, asyncOpAcquire, asyncOpRelease, awaitLastFut, cache, checkJta, clear, clear, clear, clearAll, clearAsync, clearAsync, clearAsync, clearLocally, clearLocally, clearLocally, clearLocallyAll, commitTxAsync, configuration, containsKey, containsKeyAsync, containsKeys, containsKeysAsync, containsValue, context, entries, entryEx, entryEx, entryExSafe, entrySet, entrySetx, evict, evictAll, evictAll, expiry, expiryPolicy, flags, flagsOff, flagsOn, forceRepartition, forSubjectId, get, get, get, getAll, getAll, getAllAsync, getAllAsync, getAllAsync, getAllAsync, getAllAsync0, getAllOutTx, getAllOutTxAsync, getAsync, getAsync, getForcePrimary, getForcePrimaryAsync, globalPrimarySize, globalSize, gridProjection, igniteIterator, invoke, invokeAll, invokeAll, invokeAllAsync, invokeAllAsync, invokeAsync, isColocated, isDht, isDhtAtomic, isEmpty, isLocal, isLockedByThread, iterator, iterator, keepPortable, keepPortable0, keySet, loadAll, localEntries, localPeek, localRemoveAll, localRemoveAll, localSize, lock, lockAll, lockAsync, log, map, metrics, metrics0, mxBean, name, onDeferredDelete, onKernalStart, onKernalStop, onUndeploy, overflowSize, peek, peek0, peek0, peek0, peekAll0, peekEx, peekEx, predicate, primaryEntrySet, primaryEntrySetx, primaryKeySet, primaryValues, printMemoryStats, projection, projection, put, put, putAll, putAllAsync, putAllConflict, putAllConflictAsync, putAsync, putAsync, putIfAbsent, putIfAbsentAsync, putx, putx, putxAsync, putxAsync, putxIfAbsent, putxIfAbsentAsync, queries, readExternal, readResolve, reloadAllAsync0, reloadAsync, remove, remove, remove, removeAll, removeAllAsync, removeAllConflict, removeAllConflictAsync, removeAsync, removeAsync, removeAsync, removeEntry, removeIfObsolete, removex, removex, removex, removexAsync, removexAsync, removexAsync, replace, replace, replaceAsync, replaceAsync, replacex, replacex, replacexAsync, replacexAsync, saveFuture, size, sizeAsync, start, startInfo, stop, stopInfo, toMap, tryPutIfAbsent, tx, txStart, txStart, txStart, txStartEx, txSynchronizations, txSynchronize, txUnsynchronize, unlock, validateCacheKey, validateCacheKeys, values, withExpiryPolicy, writeExternal`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.internal.processors.cache.CacheProjection

`unlockAll`

### Constructor Detail

#### GridNearCacheAdapter

    protected GridNearCacheAdapter()

Empty constructor required for `Externalizable`.

#### GridNearCacheAdapter

    protected GridNearCacheAdapter(GridCacheContext<K,V> ctx)

Parameters:
  `ctx` - Context.

### Method Detail

#### init

    protected void init()

Post constructor initialization for subclasses.

Overrides:
  `init` in class `GridCacheAdapter<K,V>`

#### dht

    public abstract GridDhtCacheAdapter<K,V> dht()

Returns:
  DHT cache.

#### isNear

    public boolean isNear()

Overrides:
  `isNear` in class `GridCacheAdapter<K,V>`
Returns:
  `True` if this is near cache.

#### preloader

    public GridCachePreloader<K,V> preloader()

Specified by:
  `preloader` in class `GridCacheAdapter<K,V>`
Returns:
  Preloader.

#### entryEx

    public GridCacheEntryEx entryEx(KeyCacheObject key,
                           boolean touch)

Overrides:
  `entryEx` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Entry key.
  `touch` - Whether created entry should be touched.
Returns:
  Entry (never `null`).

#### entryEx

    public GridCacheEntryEx entryEx(KeyCacheObject key,
                           AffinityTopologyVersion topVer)

Overrides:
  `entryEx` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Entry key.
  `topVer` - Topology version.
Returns:
  Entry (never `null`).

#### entryExx

    public GridNearCacheEntry entryExx(KeyCacheObject key,
                              AffinityTopologyVersion topVer)

Parameters:
  `key` - Key.
  `topVer` - Topology version.
Returns:
  Entry.

#### peekExx

    @Nullable
    public GridNearCacheEntry peekExx(KeyCacheObject key)

Parameters:
  `key` - Key.
Returns:
  Entry.

#### isLocked

    public boolean isLocked(K key)

Checks if any node owns a lock for this key.

This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.

Specified by:
  `isLocked` in interface `CacheProjection<K,V>`
Overrides:
  `isLocked` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Key to check.
Returns:
  `True` if lock is owned by some node.

#### isLockedNearOnly

    public boolean isLockedNearOnly(K key)

Parameters:
  `key` - Key.
Returns:
  If near entry is locked.

#### isAllLockedNearOnly

    public boolean isAllLockedNearOnly(Iterable<? extends K> keys)

Parameters:
  `keys` - Keys.
Returns:
  If near entries for given keys are locked.

#### readThroughAllAsync

    public IgniteInternalFuture<Object> readThroughAllAsync(Collection<KeyCacheObject> keys,
                                                   boolean reload,
                                                   boolean skipVals,
                                                   IgniteInternalTx tx,
                                                   @Nullable
                                                   UUID subjId,
                                                   String taskName,
                                                   IgniteBiInClosure<KeyCacheObject,Object> vis)

Overrides:
  `readThroughAllAsync` in class `GridCacheAdapter<K,V>`
Parameters:
  `keys` - Keys.
  `reload` - Reload flag.
  `tx` - Transaction.
  `subjId` - Subject ID.
  `taskName` - Task name.
  `vis` - Visitor.
Returns:
  Future.

#### reload

    public V reload(K key)
             throws IgniteCheckedException

Reloads a single key from persistent storage. This method delegates to `CacheStore#load(Transaction, Object)` method.

## Transactions

This method does not participate in transactions, however it does not violate cache integrity and can be used safely with or without transactions.

Specified by:
  `reload` in interface `CacheProjection<K,V>`
Overrides:
  `reload` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Key.
Returns:
  Reloaded value.
Throws:
  `IgniteCheckedException` - If failed.

#### loadAsync

    public IgniteInternalFuture<Map<K,V>> loadAsync(@Nullable
                                           IgniteInternalTx tx,
                                           @Nullable
                                           Collection<KeyCacheObject> keys,
                                           boolean reload,
                                           boolean forcePrimary,
                                           @Nullable
                                           UUID subjId,
                                           String taskName,
                                           boolean deserializePortable,
                                           @Nullable
                                           javax.cache.expiry.ExpiryPolicy expiryPlc,
                                           boolean skipVal)

Parameters:
  `tx` - Transaction.
  `keys` - Keys to load.
  `reload` - Reload flag.
  `forcePrimary` - Force primary flag.
  `subjId` - Subject ID.
  `taskName` - Task name.
  `deserializePortable` - Deserialize portable flag.
  `expiryPlc` - Expiry policy.
Returns:
  Loaded values.

#### localLoadCache

    public void localLoadCache(IgniteBiPredicate<K,V> p,
                      Object[] args)
                        throws IgniteCheckedException

Delegates to `CacheStore.loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)` method to load state from the underlying persistent storage. The loaded values will then be given to the optionally passed in predicate, and, if the predicate returns `true`, will be stored in cache. If predicate is `null`, then all loaded values will be stored in cache.

Note that this method does not receive keys as a parameter, so it is up to `CacheStore` implementation to provide all the data to be loaded.

This method is not transactional and may end up loading a stale value into cache if another thread has updated the value immediately after it has been loaded. It is mostly useful when pre-loading the cache from underlying data store before start, or for read-only caches.

Specified by:
  `localLoadCache` in interface `GridCacheProjectionEx<K,V>`
Overrides:
  `localLoadCache` in class `GridCacheAdapter<K,V>`
Parameters:
  `p` - Optional predicate (may be `null`). If provided, will be used to filter values to be put into cache.
  `args` - Optional user arguments to be passed into `CacheStore.loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)` method.
Throws:
  `IgniteCheckedException` - If loading failed.

#### localLoad

    public void localLoad(Collection<? extends K> keys,
                 javax.cache.expiry.ExpiryPolicy plc)
                   throws IgniteCheckedException

Overrides:
  `localLoad` in class `GridCacheAdapter<K,V>`
Parameters:
  `keys` - Keys to load.
  `plc` - Optional expiry policy.
Throws:
  `IgniteCheckedException` - If failed.

#### localLoadCacheAsync

    public IgniteInternalFuture<?> localLoadCacheAsync(IgniteBiPredicate<K,V> p,
                                              Object[] args)

Asynchronously delegates to `CacheStore.loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)` method to reload state from the underlying persistent storage. The reloaded values will then be given to the optionally passed in predicate, and if the predicate returns `true`, will be stored in cache. If predicate is `null`, then all reloaded values will be stored in cache.

Note that this method does not receive keys as a parameter, so it is up to `CacheStore` implementation to provide all the data to be loaded.

This method is not transactional and may end up loading a stale value into cache if another thread has updated the value immediately after it has been loaded. It is mostly useful when pre-loading the cache from underlying data store before start, or for read-only caches.

Specified by:
  `localLoadCacheAsync` in interface `GridCacheProjectionEx<K,V>`
Overrides:
  `localLoadCacheAsync` in class `GridCacheAdapter<K,V>`
Parameters:
  `p` - Optional predicate (may be `null`). If provided, will be used to filter values to be put into cache.
  `args` - Optional user arguments to be passed into `CacheStore.loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)` method.
Returns:
  Future to be completed whenever loading completes.

#### processGetResponse

    protected void processGetResponse(UUID nodeId,
                          GridNearGetResponse res)

Parameters:
  `nodeId` - Sender ID.
  `res` - Response.

#### size

    public int size()

Gets the number of all entries cached on this node. This method will return the count of all cache entries and has O(1) complexity on base `GridCache` projection. It is essentially the size of cache key set and is semantically identical to {`Cache.keySet().size()`.

NOTE: this operation is not distributed and returns only the number of entries cached on this node.

Specified by:
  `size` in interface `CacheProjection<K,V>`
Overrides:
  `size` in class `GridCacheAdapter<K,V>`
Returns:
  Size of cache on this node.

#### primarySize

    public int primarySize()

Gets the number of all primary entries cached on this node. For `CacheMode.LOCAL` non-distributed cache mode, this method is identical to `CacheProjection.size()`.

For `CacheMode.PARTITIONED` and `CacheMode.REPLICATED` modes, this method will return number of primary entries cached on this node (excluding any backups). The complexity of this method is O(P), where P is the total number of partitions.

NOTE: this operation is not distributed and returns only the number of primary entries cached on this node.

Specified by:
  `primarySize` in interface `CacheProjection<K,V>`
Overrides:
  `primarySize` in class `GridCacheAdapter<K,V>`
Returns:
  Number of primary entries in cache.

#### nearSize

    public int nearSize()

Gets size of near cache key set. This method will return count of all entries in near cache and has O(1) complexity on base cache projection.

Note that for `LOCAL` non-distributed caches this method will always return `0`

Specified by:
  `nearSize` in interface `CacheProjection<K,V>`
Overrides:
  `nearSize` in class `GridCacheAdapter<K,V>`
Returns:
  Size of near cache key set or `0` if cache is not `CacheMode.PARTITIONED`.

#### nearEntries

    public Set<javax.cache.Cache.Entry<K,V>> nearEntries()

Returns:
  Near entries.

#### entrySet

    public Set<javax.cache.Cache.Entry<K,V>> entrySet(@Nullable
                                             CacheEntryPredicate... filter)

Overrides:
  `entrySet` in class `GridCacheAdapter<K,V>`
Parameters:
  `filter` - Filters to evaluate.
Returns:
  Entry set.

#### entrySet

    public Set<javax.cache.Cache.Entry<K,V>> entrySet(int part)

Gets set containing cache entries that belong to provided partition or `null` if partition is not found locally.

NOTE: this operation is not distributed and returns only the entries cached on this node.

Specified by:
  `entrySet` in interface `CacheProjection<K,V>`
Overrides:
  `entrySet` in class `GridCacheAdapter<K,V>`
Parameters:
  `part` - Partition.
Returns:
  Set containing partition's entries or `null` if partition is not found locally.

#### primaryEntrySet

    public Set<javax.cache.Cache.Entry<K,V>> primaryEntrySet(@Nullable
                                                    CacheEntryPredicate... filter)

Overrides:
  `primaryEntrySet` in class `GridCacheAdapter<K,V>`
Parameters:
  `filter` - Filters to evaluate.
Returns:
  Primary entry set.

#### keySet

    public Set<K> keySet(@Nullable
                CacheEntryPredicate[] filter)

Set of keys cached on this node. You can remove elements from this set, but you cannot add elements to this set. All removal operation will be reflected on the cache itself.

Iterator over this set will not fail if set was concurrently updated by another thread. This means that iterator may or may not return latest keys depending on whether they were added before or after current iterator position.

NOTE: this operation is not distributed and returns only the keys cached on this node.

Specified by:
  `keySet` in interface `CacheProjection<K,V>`
Overrides:
  `keySet` in class `GridCacheAdapter<K,V>`
Parameters:
  `filter` - Filters to evaluate.
Returns:
  Key set.

#### nearKeySet

    public Set<K> nearKeySet(@Nullable
                    CacheEntryPredicate filter)

Parameters:
  `filter` - Entry filter.
Returns:
  Keys for near cache only.

#### primaryKeySet

    public Set<K> primaryKeySet(@Nullable
                       CacheEntryPredicate... filter)

Overrides:
  `primaryKeySet` in class `GridCacheAdapter<K,V>`
Parameters:
  `filter` - Primary key set.
Returns:
  Primary key set.

#### values

    public Collection<V> values(CacheEntryPredicate... filter)

Collection of values cached on this node. You can remove elements from this collection, but you cannot add elements to this collection. All removal operation will be reflected on the cache itself.

Iterator over this collection will not fail if collection was concurrently updated by another thread. This means that iterator may or may not return latest values depending on whether they were added before or after current iterator position.

NOTE: this operation is not distributed and returns only the values cached on this node.

Overrides:
  `values` in class `GridCacheAdapter<K,V>`
Parameters:
  `filter` - Filters.
Returns:
  Collection of cached values.

#### primaryValues

    public Collection<V> primaryValues(@Nullable
                              CacheEntryPredicate... filter)

Overrides:
  `primaryValues` in class `GridCacheAdapter<K,V>`
Parameters:
  `filter` - Filters to evaluate.
Returns:
  Primary values.

#### evict

    public boolean evict(K key,
                @Nullable
                CacheEntryPredicate[] filter)

Overrides:
  `evict` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Key.
  `filter` - Filters to evaluate.
Returns:
  `True` if evicted.

#### evictNearOnly

    public boolean evictNearOnly(K key,
                        @Nullable
                        CacheEntryPredicate[] filter)

Parameters:
  `key` - Key to evict.
  `filter` - Optional filter.
Returns:
  `True` if evicted.

#### evictAll

    public void evictAll(Collection<? extends K> keys,
                @Nullable
                CacheEntryPredicate[] filter)

Overrides:
  `evictAll` in class `GridCacheAdapter<K,V>`
Parameters:
  `keys` - Keys.
  `filter` - Filters to evaluate.

#### entry

    public javax.cache.Cache.Entry<K,V> entry(K key)

Gets entry from cache with the specified key. The returned entry can be used even after entry key has been removed from cache. In that case, every operation on returned entry will result in creation of a new entry.

Note that this method can return `null` if projection is configured as pre-filtered and entry key and value don't pass key-value filter of the projection.

Specified by:
  `entry` in interface `CacheProjection<K,V>`
Overrides:
  `entry` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Entry key.
Returns:
  Cache entry or `null` if projection pre-filtering was not passed.

#### peekNearOnly

    @Nullable
    public V peekNearOnly(K key)

Peeks only near cache without looking into DHT cache.

Parameters:
  `key` - Key.
Returns:
  Peeked value.

#### peek

    public V peek(K key,
         @Nullable
         CacheEntryPredicate filter)

Overrides:
  `peek` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Key.
  `filter` - Filter to evaluate.
Returns:
  Peeked value.

#### peek

    public V peek(K key,
         @Nullable
         Collection<GridCachePeekMode> modes)
           throws IgniteCheckedException

Peeks at cached value using optional set of peek modes. This method will sequentially iterate over given peek modes in the order passed in, and try to peek at value using each peek mode. Once a `non-null` value is found, it will be immediately returned.

Note that if modes are not provided this method works exactly the same way as `CacheProjection.peek(Object)`, implicitly using `GridCachePeekMode.SMART` mode.

## Transactions

This method does not participate in any transactions, however, it may peek at transactional value depending on the peek modes used.

Specified by:
  `peek` in interface `CacheProjection<K,V>`
Overrides:
  `peek` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Entry key.
  `modes` - Optional set of peek modes.
Returns:
  Peeked value.
Throws:
  `IgniteCheckedException` - If peek operation failed.

#### clearLocally0

    public boolean clearLocally0(K key,
                        @Nullable
                        CacheEntryPredicate[] filter)

Overrides:
  `clearLocally0` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Key.
  `filter` - Filters to evaluate.
Returns:
  `True` if cleared.

#### clearLocally0

    public void clearLocally0(Collection<? extends K> keys,
                     @Nullable
                     CacheEntryPredicate[] filter)

Overrides:
  `clearLocally0` in class `GridCacheAdapter<K,V>`
Parameters:
  `keys` - Keys.
  `filter` - Filters to evaluate.

#### promote

    public V promote(K key,
            boolean deserializePortable)
              throws IgniteCheckedException

Overrides:
  `promote` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Key.
  `deserializePortable` - Deserialize portable flag.
Returns:
  Value.
Throws:
  `IgniteCheckedException` - If failed.

#### promote

    public V promote(K key)
              throws IgniteCheckedException

This method promotes cache entry by given key, if any, from offheap or swap storage into memory.

## Transactions

This method is not transactional.

## Cache Flags

This method is not available if any of the following flags are set on projection: `CacheFlag.SKIP_SWAP`, `CacheFlag.READ`.

Specified by:
  `promote` in interface `CacheProjection<K,V>`
Overrides:
  `promote` in class `GridCacheAdapter<K,V>`
Parameters:
  `key` - Key to promote entry for.
Returns:
  Unswapped entry value or `null` for non-existing key.
Throws:
  `IgniteCheckedException` - If promote failed.

#### promoteAll

    public void promoteAll(@Nullable
                  Collection<? extends K> keys)
                    throws IgniteCheckedException

This method unswaps cache entries by given keys, if any, from swap storage into memory.

## Transactions

This method is not transactional.

## Cache Flags

This method is not available if any of the following flags are set on projection: `CacheFlag.SKIP_SWAP`, `CacheFlag.READ`.

Specified by:
  `promoteAll` in interface `CacheProjection<K,V>`
Overrides:
  `promoteAll` in class `GridCacheAdapter<K,V>`
Parameters:
  `keys` - Keys to promote entries for.
Throws:
  `IgniteCheckedException` - If promote failed.

#### randomEntry

    @Nullable
    public javax.cache.Cache.Entry<K,V> randomEntry()

Gets a random entry out of cache. In the worst cache scenario this method has complexity of

    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).

Specified by:
  `randomEntry` in interface `GridCache<K,V>`
Overrides:
  `randomEntry` in class `GridCacheAdapter<K,V>`
Returns:
  Random entry, or `null` if cache is empty.

#### swapIterator

    public Iterator<Map.Entry<K,V>> swapIterator()
                                          throws IgniteCheckedException

Gets iterator over keys and values belonging to this cache swap space on local node. This iterator is thread-safe, which means that cache (and therefore its swap space) may be modified concurrently with iteration over swap.

Returned iterator supports `remove` operation which delegates to `removex(Object, org.apache.ignite.lang.IgnitePredicate[])` method.

## Cache Flags

This method is not available if any of the following flags are set on projection: `CacheFlag.SKIP_SWAP`.

Specified by:
  `swapIterator` in interface `GridCache<K,V>`
Overrides:
  `swapIterator` in class `GridCacheAdapter<K,V>`
Returns:
  Iterator over keys.
Throws:
  `IgniteCheckedException` - If failed.
See Also:
  `CacheProjection.promote(Object)`

#### offHeapIterator

    public Iterator<Map.Entry<K,V>> offHeapIterator()
                                             throws IgniteCheckedException

Gets iterator over keys and values belonging to this cache off-heap memory on local node. This iterator is thread-safe, which means that cache (and therefore its off-heap memory) may be modified concurrently with iteration over off-heap. To achieve better performance the keys and values deserialized on demand, whenever accessed.

Returned iterator supports `remove` operation which delegates to `removex(Object, org.apache.ignite.lang.IgnitePredicate[])}` method.

Specified by:
  `offHeapIterator` in interface `GridCache<K,V>`
Overrides:
  `offHeapIterator` in class `GridCacheAdapter<K,V>`
Returns:
  Iterator over keys.
Throws:
  `IgniteCheckedException` - If failed.

#### offHeapEntriesCount

    public long offHeapEntriesCount()

Gets number of cache entries stored in off-heap memory.

Specified by:
  `offHeapEntriesCount` in interface `GridCache<K,V>`
Overrides:
  `offHeapEntriesCount` in class `GridCacheAdapter<K,V>`
Returns:
  Number of cache entries stored in off-heap memory.

#### offHeapAllocatedSize

    public long offHeapAllocatedSize()

Gets memory size allocated in off-heap.

Specified by:
  `offHeapAllocatedSize` in interface `GridCache<K,V>`
Overrides:
  `offHeapAllocatedSize` in class `GridCacheAdapter<K,V>`
Returns:
  Allocated memory size.

#### swapSize

    public long swapSize()
                  throws IgniteCheckedException

Gets size in bytes for swap space.

Specified by:
  `swapSize` in interface `GridCache<K,V>`
Overrides:
  `swapSize` in class `GridCacheAdapter<K,V>`
Returns:
  Size in bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### swapKeys

    public long swapKeys()
                  throws IgniteCheckedException

Gets number of swap entries (keys).

Specified by:
  `swapKeys` in interface `GridCache<K,V>`
Overrides:
  `swapKeys` in class `GridCacheAdapter<K,V>`
Returns:
  Number of entries stored in swap.
Throws:
  `IgniteCheckedException` - If failed.

#### isIgfsDataCache

    public boolean isIgfsDataCache()

Checks whether this cache is IGFS data cache.

Specified by:
  `isIgfsDataCache` in interface `GridCacheProjectionEx<K,V>`
Overrides:
  `isIgfsDataCache` in class `GridCacheAdapter<K,V>`
Returns:
  `True` in case this cache is IGFS data cache.

#### igfsDataSpaceUsed

    public long igfsDataSpaceUsed()

Get current amount of used IGFS space in bytes.

Specified by:
  `igfsDataSpaceUsed` in interface `GridCacheProjectionEx<K,V>`
Overrides:
  `igfsDataSpaceUsed` in class `GridCacheAdapter<K,V>`
Returns:
  Amount of used IGFS space in bytes.

#### igfsDataSpaceMax

    public long igfsDataSpaceMax()

Get maximum space available for IGFS.

Specified by:
  `igfsDataSpaceMax` in interface `GridCacheProjectionEx<K,V>`
Overrides:
  `igfsDataSpaceMax` in class `GridCacheAdapter<K,V>`
Returns:
  Amount of space available for IGFS in bytes.

#### onIgfsDataSizeChanged

    public void onIgfsDataSizeChanged(long delta)

Callback invoked when data is added to IGFS cache.

Overrides:
  `onIgfsDataSizeChanged` in class `GridCacheAdapter<K,V>`
Parameters:
  `delta` - Size delta.

#### isMongoDataCache

    public boolean isMongoDataCache()

Checks whether this cache is Mongo data cache.

Specified by:
  `isMongoDataCache` in interface `GridCacheProjectionEx<K,V>`
Overrides:
  `isMongoDataCache` in class `GridCacheAdapter<K,V>`
Returns:
  `True` if this cache is mongo data cache.

#### isMongoMetaCache

    public boolean isMongoMetaCache()

Checks whether this cache is Mongo meta cache.

Specified by:
  `isMongoMetaCache` in interface `GridCacheProjectionEx<K,V>`
Overrides:
  `isMongoMetaCache` in class `GridCacheAdapter<K,V>`
Returns:
  `True` if this cache is mongo meta cache.

#### splitClearLocally

    public List<GridCacheClearAllRunnable<K,V>> splitClearLocally()

Split clearLocally all task into multiple runnables.

Overrides:
  `splitClearLocally` in class `GridCacheAdapter<K,V>`
Returns:
  Split runnables.

#### nearEntriesIterator

    public Iterator<javax.cache.Cache.Entry<K,V>> nearEntriesIterator()

Returns:
  Near entries iterator.

#### toString

    public String toString()

Overrides:
  `toString` in class `GridDistributedCacheAdapter<K,V>`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0
Release Date | : March 31 2015