org.apache.ignite.internal.processors.cache.local

## Class GridLocalCache<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheAdapter<K,V>
  - - org.apache.ignite.internal.processors.cache.local.GridLocalCache<K,V>

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

Direct Known Subclasses:
  GridLocalAtomicCache

    public class GridLocalCache<K,V>
    extends GridCacheAdapter<K,V>

Local cache implementation.

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.PeekModes, GridCacheAdapter.TopologyVersionAwareJob, 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, DFLT_START_CACHE_SIZE, keyCheck, lastFut, locNodeId, log, map, MAX_RETRIES, metrics, RET2NULL, txLockMsgLog`

### Constructor Summary

Constructors
Constructor and Description
`GridLocalCache()` Empty constructor required by `Externalizable`.
`GridLocalCache(GridCacheContext<K,V> ctx)`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `isLocal()`
`long` `localSizeLong(CachePeekMode[] peekModes)`
`long` `localSizeLong(int part, CachePeekMode[] peekModes)`
`IgniteInternalFuture<Boolean>` `lockAllAsync(Collection<? extends K> keys, long timeout)` All or nothing synchronous lock for passed in keys.
`IgniteInternalFuture<Boolean>` `lockAllAsync(Collection<KeyCacheObject> keys, long timeout, IgniteTxLocalEx tx, CacheEntryPredicate[] filter)`
`void` `onDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver)`
`GridCachePreloader` `preloader()`
`IgniteInternalFuture<?>` `removeAllAsync()`
`void` `start()` Starts this cache.
`IgniteInternalFuture<Boolean>` `txLockAsync(Collection<KeyCacheObject> keys, long timeout, IgniteTxLocalEx tx, boolean isRead, boolean retval, TransactionIsolation isolation, boolean invalidate, long createTtl, long accessTtl)`
`void` `unlockAll(Collection<? extends K> keys)` Unlocks given keys only if current thread owns the locks.

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

`active, active, affinity, allEntries, asyncOp, asyncOpAcquire, asyncOpRelease, awaitLastFut, cache, checkJta, clear, clear, clearAll, clearAllAsync, clearAsync, clearAsync, clearLocally, clearLocally, clearLocally, clearLocallyAll, clusterMetrics, clusterMetrics, clusterMxBean, configuration, containsKey, containsKeyAsync, containsKeys, containsKeysAsync, context, decrementSize, entries, entryEx, entryEx, entryEx, entrySet, entrySet, evict, evictAll, expiry, expiryPolicy, forceKeyCheck, forSubjectId, get, get, get0, getAll, getAll0, getAllAsync, getAllAsync, getAllAsync, getAllAsync, getAllAsync0, getAllOutTx, getAllOutTxAsync, getAndPut, getAndPut, getAndPut0, getAndPutAsync, getAndPutAsync, getAndPutAsync0, getAndPutIfAbsent, getAndPutIfAbsentAsync, getAndRemove, getAndRemove0, getAndRemoveAsync, getAndRemoveAsync0, getAndReplace, getAndReplaceAsync, getAsync, getAsync, getAsync, getEntries, getEntriesAsync, getEntry, getEntryAsync, getForcePrimary, getForcePrimaryAsync, igfsDataSpaceUsed, igniteIterator, igniteIterator, incrementSize, init, invoke, invoke, invokeAll, invokeAll, invokeAllAsync, invokeAllAsync, invokeAsync, isColocated, isDht, isDhtAtomic, isEmpty, isIgfsDataCache, isLocked, isLockedByThread, isMongoDataCache, isMongoMetaCache, isNear, iterator, iterator, keepBinary, keySet, loadAll, localEntries, localLoad, localLoadCache, localLoadCacheAsync, localMetrics, localMxBean, localPeek, localSize, lock, lockAll, lockAsync, log, lostPartitions, map, metrics0, name, nearSize, offHeapAllocatedSize, offHeapEntriesCount, onIgfsDataSizeChanged, onKernalStart, onKernalStop, onReconnected, onUndeploy, parsePeekModes, peekEx, peekEx, primarySize, primarySizeLong, printMemoryStats, put, put, put0, putAll, putAll0, putAllAsync, putAllAsync0, putAllConflict, putAllConflictAsync, putAsync, putAsync, putAsync0, putIfAbsent, putIfAbsentAsync, readExternal, readResolve, rebalance, remove, remove, remove, remove0, removeAll, removeAll, removeAll0, removeAllAsync, removeAllAsync0, removeAllConflict, removeAllConflictAsync, removeAsync, removeAsync, removeAsync, removeAsync0, removeEntry, removeIfObsolete, replace, replace, replaceAsync, replaceAsync, saveFuture, scanIterator, setSkipStore, size, size, sizeAsync, sizeLong, sizeLong, sizeLong, sizeLongAsync, sizeLongAsync, skipStore, splitClearLocally, startInfo, stop, stopInfo, toString, tx, txStart, txStart, txStartEx, unlock, validateCacheKey, validateCacheKeys, withExpiryPolicy, withNoRetries, writeExternal`

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

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

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Constructor Detail

#### GridLocalCache

    public GridLocalCache()

Empty constructor required by `Externalizable`.

#### GridLocalCache

    public GridLocalCache(GridCacheContext<K,V> ctx)

Parameters:
  `ctx` - Cache registry.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts this cache. Child classes should override this method to provide custom start-up behavior.

Specified by:
  `start` in class `GridCacheAdapter<K,V>`
Throws:
  `IgniteCheckedException` - If start failed.

#### isLocal

    public boolean isLocal()

Overrides:
  `isLocal` in class `GridCacheAdapter<K,V>`
Returns:
  `True` if cache is local.

#### preloader

    public GridCachePreloader preloader()

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

#### txLockAsync

    public IgniteInternalFuture<Boolean> txLockAsync(Collection<KeyCacheObject> keys,
                                                     long timeout,
                                                     IgniteTxLocalEx tx,
                                                     boolean isRead,
                                                     boolean retval,
                                                     TransactionIsolation isolation,
                                                     boolean invalidate,
                                                     long createTtl,
                                                     long accessTtl)

Specified by:
  `txLockAsync` in class `GridCacheAdapter<K,V>`
Parameters:
  `keys` - Keys to lock.
  `timeout` - Lock timeout.
  `tx` - Transaction.
  `isRead` - `True` for read operations.
  `retval` - Flag to return value.
  `isolation` - Transaction isolation.
  `invalidate` - Invalidate flag.
  `createTtl` - TTL for create operation.
  `accessTtl` - TTL for read operation.
Returns:
  Locks future.

#### lockAllAsync

    public IgniteInternalFuture<Boolean> lockAllAsync(Collection<? extends K> keys,
                                                      long timeout)

All or nothing synchronous lock for passed in keys. This method together with filter check will be executed as one atomic operation. If at least one filter validation failed, no locks will be acquired.

## Transactions

Locks are not transactional and should not be used from within transactions. If you do need explicit locking within transaction, then you should use `TransactionConcurrency.PESSIMISTIC` concurrency control for transaction which will acquire explicit locks for relevant cache operations.

Parameters:
  `keys` - Keys to lock.
  `timeout` - Timeout in milliseconds to wait for lock to be acquired (`'0'` for no expiration).
Returns:
  Future for the collection of locks. The future will return `true` if all filters passed and locks were acquired before timeout has expired, `false` otherwise.

#### lockAllAsync

    public IgniteInternalFuture<Boolean> lockAllAsync(Collection<KeyCacheObject> keys,
                                                      long timeout,
                                                      @Nullable
                                                      IgniteTxLocalEx tx,
                                                      CacheEntryPredicate[] filter)

Parameters:
  `keys` - Keys.
  `timeout` - Timeout.
  `tx` - Transaction.
  `filter` - Filter.
Returns:
  Future.

#### unlockAll

    public void unlockAll(Collection<? extends K> keys)
                   throws IgniteCheckedException

Unlocks given keys only if current thread owns the locks. Only the keys that have been locked by calling thread and pass through the filter (if any) will be unlocked. If none of the key locks is owned by current thread, then this method will do nothing.

## Transactions

Locks are not transactional and should not be used from within transactions. If you do need explicit locking within transaction, then you should use `TransactionConcurrency.PESSIMISTIC` concurrency control for transaction which will acquire explicit locks for relevant cache operations.

Parameters:
  `keys` - Keys to unlock.
Throws:
  `IgniteCheckedException` - If unlock execution resulted in error.

#### removeAllAsync

    public IgniteInternalFuture<?> removeAllAsync()

Returns:
  Remove future.

#### onDeferredDelete

    public void onDeferredDelete(GridCacheEntryEx entry,
                                 GridCacheVersion ver)

Specified by:
  `onDeferredDelete` in class `GridCacheAdapter<K,V>`
Parameters:
  `entry` - Entry.
  `ver` - Version.

#### localSizeLong

    public long localSizeLong(CachePeekMode[] peekModes)
                       throws IgniteCheckedException

Parameters:
  `peekModes` - Peek modes.
Returns:
  Local cache size as a long value.
Throws:
  `IgniteCheckedException` - If failed.

#### localSizeLong

    public long localSizeLong(int part,
                              CachePeekMode[] peekModes)
                       throws IgniteCheckedException

Parameters:
  `part` - partition.
  `peekModes` - Peek modes.
Returns:
  Local cache size as a long value.
Throws:
  `IgniteCheckedException` - If failed.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.6.0
Release Date | : July 10 2018