org.apache.ignite.internal.processors.platform.cache

## Class PlatformCache

- java.lang.Object
- - org.apache.ignite.internal.processors.platform.PlatformAbstractTarget
  - - org.apache.ignite.internal.processors.platform.cache.PlatformCache

All Implemented Interfaces:
  PlatformTarget

    public class PlatformCache
    extends PlatformAbstractTarget

Native cache wrapper implementation.

### Field Summary

Fields
`static int` `OP_CLEAR`
`static int` `OP_CLEAR_ALL`
`static int` `OP_CONTAINS_KEY`
`static int` `OP_CONTAINS_KEYS`
`static int` `OP_GET`
`static int` `OP_GET_ALL`
`static int` `OP_GET_AND_PUT`
`static int` `OP_GET_AND_PUT_IF_ABSENT`
`static int` `OP_GET_AND_REMOVE`
`static int` `OP_GET_AND_REPLACE`
`static int` `OP_GET_NAME`
`static int` `OP_INVOKE`
`static int` `OP_INVOKE_ALL`
`static int` `OP_IS_LOCAL_LOCKED`
`static int` `OP_LOAD_CACHE`
`static int` `OP_LOC_EVICT`
`static int` `OP_LOC_LOAD_CACHE`
`static int` `OP_LOC_PROMOTE`
`static int` `OP_LOCAL_CLEAR`
`static int` `OP_LOCAL_CLEAR_ALL`
`static int` `OP_LOCK`
`static int` `OP_LOCK_ALL`
`static int` `OP_METRICS`
`static int` `OP_PUT_IF_ABSENT`
`static int` `OP_QRY_CONTINUOUS`
`static int` `OP_QRY_SCAN`
`static int` `OP_QRY_SQL`
`static int` `OP_QRY_SQL_FIELDS`
`static int` `OP_QRY_TXT`
`static int` `OP_REMOVE_ALL`
`static int` `OP_REMOVE_BOOL`
`static int` `OP_REMOVE_OBJ`
`static int` `OP_REPLACE_2`
`static int` `OP_REPLACE_3`

### Fields inherited from class org.apache.ignite.internal.processors.platform.PlatformAbstractTarget

`FALSE, log, platformCtx, TRUE`

### Constructor Summary

Constructors
Constructor and Description
`PlatformCache(PlatformContext platformCtx, IgniteCache cache, boolean keepPortable)` Constructor.

### Method Summary

Methods
`void` `clear()` Clears the contents of the cache, without notifying listeners or `CacheWriter`s.
`void` `closeLock(long id)` Unregister lock.
`Exception` `convertException(Exception e)` Convert caught exception.
`protected IgniteFuture` `currentFuture()` <inheritDoc />
`void` `enterLock(long id)` Enters a lock.
`void` `exitLock(long id)` Exits a lock.
`protected PlatformFutureUtils.Writer` `futureWriter(int opId)` <inheritDoc />
`PlatformCacheIterator` `iterator()` Create cache iterator.
`PlatformCacheIterator` `localIterator(int peekModes)` Create cache iterator over local entries.
`protected long` `processInStreamOutLong(int type, BinaryRawReaderEx reader)` Process IN operation.
`protected Object` `processInStreamOutObject(int type, BinaryRawReaderEx reader)` Process IN operation with managed object as result.
`protected void` `processInStreamOutStream(int type, BinaryRawReaderEx reader, BinaryRawWriterEx writer)` Process IN-OUT operation.
`protected void` `processOutStream(int type, BinaryRawWriterEx writer)` Process OUT operation.
`void` `rebalance(long futId)` Rebalances the cache.
`void` `removeAll()` Removes all entries.
`int` `size(int peekModes, boolean loc)` Read cache size.
`boolean` `tryEnterLock(long id, long timeout)` Attempts to enter a lock.
`PlatformCache` `withAsync()` Gets cache with asynchronous mode enabled.
`PlatformCache` `withExpiryPolicy(long create, long update, long access)` Gets cache with provided expiry policy.
`PlatformCache` `withKeepPortable()` Gets cache with "keep portable" flag.
`PlatformCache` `withNoRetries()` Gets cache with no-retries mode enabled.
`PlatformCache` `withSkipStore()` Gets cache with "skip-store" flag set.

### Methods inherited from class org.apache.ignite.internal.processors.platform.PlatformAbstractTarget

`currentFutureWrapped, inObjectStreamOutStream, inStreamOutLong, inStreamOutObject, inStreamOutStream, listenFuture, listenFutureForOperation, outLong, outObject, outStream, platformContext, processInObjectStreamOutStream, processOutLong, processOutObject, throwUnsupported`

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

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

### Field Detail

#### OP_CLEAR

    public static final int OP_CLEAR

See Also:
  Constant Field Values

#### OP_CLEAR_ALL

    public static final int OP_CLEAR_ALL

See Also:
  Constant Field Values

#### OP_CONTAINS_KEY

    public static final int OP_CONTAINS_KEY

See Also:
  Constant Field Values

#### OP_CONTAINS_KEYS

    public static final int OP_CONTAINS_KEYS

See Also:
  Constant Field Values

#### OP_GET

    public static final int OP_GET

See Also:
  Constant Field Values

#### OP_GET_ALL

    public static final int OP_GET_ALL

See Also:
  Constant Field Values

#### OP_GET_AND_PUT

    public static final int OP_GET_AND_PUT

See Also:
  Constant Field Values

#### OP_GET_AND_PUT_IF_ABSENT

    public static final int OP_GET_AND_PUT_IF_ABSENT

See Also:
  Constant Field Values

#### OP_GET_AND_REMOVE

    public static final int OP_GET_AND_REMOVE

See Also:
  Constant Field Values

#### OP_GET_AND_REPLACE

    public static final int OP_GET_AND_REPLACE

See Also:
  Constant Field Values

#### OP_GET_NAME

    public static final int OP_GET_NAME

See Also:
  Constant Field Values

#### OP_INVOKE

    public static final int OP_INVOKE

See Also:
  Constant Field Values

#### OP_INVOKE_ALL

    public static final int OP_INVOKE_ALL

See Also:
  Constant Field Values

#### OP_IS_LOCAL_LOCKED

    public static final int OP_IS_LOCAL_LOCKED

See Also:
  Constant Field Values

#### OP_LOAD_CACHE

    public static final int OP_LOAD_CACHE

See Also:
  Constant Field Values

#### OP_LOC_EVICT

    public static final int OP_LOC_EVICT

See Also:
  Constant Field Values

#### OP_LOC_LOAD_CACHE

    public static final int OP_LOC_LOAD_CACHE

See Also:
  Constant Field Values

#### OP_LOC_PROMOTE

    public static final int OP_LOC_PROMOTE

See Also:
  Constant Field Values

#### OP_LOCAL_CLEAR

    public static final int OP_LOCAL_CLEAR

See Also:
  Constant Field Values

#### OP_LOCAL_CLEAR_ALL

    public static final int OP_LOCAL_CLEAR_ALL

See Also:
  Constant Field Values

#### OP_LOCK

    public static final int OP_LOCK

See Also:
  Constant Field Values

#### OP_LOCK_ALL

    public static final int OP_LOCK_ALL

See Also:
  Constant Field Values

#### OP_METRICS

    public static final int OP_METRICS

See Also:
  Constant Field Values

#### OP_PUT_IF_ABSENT

    public static final int OP_PUT_IF_ABSENT

See Also:
  Constant Field Values

#### OP_QRY_CONTINUOUS

    public static final int OP_QRY_CONTINUOUS

See Also:
  Constant Field Values

#### OP_QRY_SCAN

    public static final int OP_QRY_SCAN

See Also:
  Constant Field Values

#### OP_QRY_SQL

    public static final int OP_QRY_SQL

See Also:
  Constant Field Values

#### OP_QRY_SQL_FIELDS

    public static final int OP_QRY_SQL_FIELDS

See Also:
  Constant Field Values

#### OP_QRY_TXT

    public static final int OP_QRY_TXT

See Also:
  Constant Field Values

#### OP_REMOVE_ALL

    public static final int OP_REMOVE_ALL

See Also:
  Constant Field Values

#### OP_REMOVE_BOOL

    public static final int OP_REMOVE_BOOL

See Also:
  Constant Field Values

#### OP_REMOVE_OBJ

    public static final int OP_REMOVE_OBJ

See Also:
  Constant Field Values

#### OP_REPLACE_2

    public static final int OP_REPLACE_2

See Also:
  Constant Field Values

#### OP_REPLACE_3

    public static final int OP_REPLACE_3

See Also:
  Constant Field Values

### Constructor Detail

#### PlatformCache

    public PlatformCache(PlatformContext platformCtx,
                 IgniteCache cache,
                 boolean keepPortable)

Constructor.

Parameters:
  `platformCtx` - Context.
  `cache` - Underlying cache.
  `keepPortable` - Keep portable flag.

### Method Detail

#### withSkipStore

    public PlatformCache withSkipStore()

Gets cache with "skip-store" flag set.

Returns:
  Cache with "skip-store" flag set.

#### withKeepPortable

    public PlatformCache withKeepPortable()

Gets cache with "keep portable" flag.

Returns:
  Cache with "keep portable" flag set.

#### withExpiryPolicy

    public PlatformCache withExpiryPolicy(long create,
                                 long update,
                                 long access)

Gets cache with provided expiry policy.

Parameters:
  `create` - Create.
  `update` - Update.
  `access` - Access.
Returns:
  Cache.

#### withAsync

    public PlatformCache withAsync()

Gets cache with asynchronous mode enabled.

Returns:
  Cache with asynchronous mode enabled.

#### withNoRetries

    public PlatformCache withNoRetries()

Gets cache with no-retries mode enabled.

Returns:
  Cache with no-retries mode enabled.

#### processInStreamOutLong

    protected long processInStreamOutLong(int type,
                              BinaryRawReaderEx reader)
                                   throws IgniteCheckedException

Process IN operation.

Overrides:
  `processInStreamOutLong` in class `PlatformAbstractTarget`
Parameters:
  `type` - Type.
  `reader` - Portable reader.
Returns:
  Result.
Throws:
  `IgniteCheckedException` - In case of exception.

#### processInStreamOutObject

    protected Object processInStreamOutObject(int type,
                                  BinaryRawReaderEx reader)
                                       throws IgniteCheckedException

Process IN operation with managed object as result.

Overrides:
  `processInStreamOutObject` in class `PlatformAbstractTarget`
Parameters:
  `type` - Type.
  `reader` - Portable reader.
Returns:
  Result.
Throws:
  `IgniteCheckedException` - In case of exception.

#### processOutStream

    protected void processOutStream(int type,
                        BinaryRawWriterEx writer)
                             throws IgniteCheckedException

Process OUT operation.

Overrides:
  `processOutStream` in class `PlatformAbstractTarget`
Parameters:
  `type` - Type.
  `writer` - Portable writer.
Throws:
  `IgniteCheckedException` - In case of exception.

#### processInStreamOutStream

    protected void processInStreamOutStream(int type,
                                BinaryRawReaderEx reader,
                                BinaryRawWriterEx writer)
                                     throws IgniteCheckedException

Process IN-OUT operation.

Overrides:
  `processInStreamOutStream` in class `PlatformAbstractTarget`
Parameters:
  `type` - Type.
  `reader` - Portable reader.
  `writer` - Portable writer.
Throws:
  `IgniteCheckedException` - In case of exception.

#### convertException

    public Exception convertException(Exception e)

Convert caught exception.

Overrides:
  `convertException` in class `PlatformAbstractTarget`
Parameters:
  `e` - Exception to convert.
Returns:
  Converted exception.

#### currentFuture

    protected IgniteFuture currentFuture()
                                  throws IgniteCheckedException

<inheritDoc />

Overrides:
  `currentFuture` in class `PlatformAbstractTarget`
Returns:
  current future.
Throws:
  `IgniteCheckedException`

#### futureWriter

    @Nullable
    protected PlatformFutureUtils.Writer futureWriter(int opId)

<inheritDoc />

Overrides:
  `futureWriter` in class `PlatformAbstractTarget`
Parameters:
  `opId` - Operation id.
Returns:
  A custom writer for given op id.

#### clear

    public void clear()
               throws IgniteCheckedException

Clears the contents of the cache, without notifying listeners or `CacheWriter`s.

Throws:
  `IllegalStateException` - if the cache is closed.
  `javax.cache.CacheException` - if there is a problem during the clear
  `IgniteCheckedException`

#### removeAll

    public void removeAll()
                   throws IgniteCheckedException

Removes all entries.

Throws:
  `IgniteCheckedException` - In case of error.

#### size

    public int size(int peekModes,
           boolean loc)

Read cache size.

Parameters:
  `peekModes` - Encoded peek modes.
  `loc` - Local mode flag.
Returns:
  Size.

#### iterator

    public PlatformCacheIterator iterator()

Create cache iterator.

Returns:
  Cache iterator.

#### localIterator

    public PlatformCacheIterator localIterator(int peekModes)

Create cache iterator over local entries.

Parameters:
  `peekModes` - Peke modes.
Returns:
  Cache iterator.

#### enterLock

    public void enterLock(long id)
                   throws InterruptedException

Enters a lock.

Parameters:
  `id` - Lock id.
Throws:
  `InterruptedException`

#### exitLock

    public void exitLock(long id)

Exits a lock.

Parameters:
  `id` - Lock id.

#### tryEnterLock

    public boolean tryEnterLock(long id,
                       long timeout)
                         throws InterruptedException

Attempts to enter a lock.

Parameters:
  `id` - Lock id.
  `timeout` - Timeout, in milliseconds. -1 for infinite timeout.
Throws:
  `InterruptedException`

#### rebalance

    public void rebalance(long futId)

Rebalances the cache.

Parameters:
  `futId` - Future id.

#### closeLock

    public void closeLock(long id)

Unregister lock.

Parameters:
  `id` - Lock id.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0-b1
Release Date | : December 1 2015