Key-Value Queries | Ignite Documentation

Ignite Summit 2025 – Call for Speakers Now Open – Learn more 

Edit

Key-Value Queries

This page describes the key-value operations that you can perform with a cache. The key-value operations are equivalent to Ignite’s native cache operations. Each operation has a header and operation-specific data.

Refer to the Data Format page for a list of available data types and data format specification.

Operation Codes

Upon successful handshake with an Ignite server node, a client can start performing various key-value operations by sending a request (see request/response structure below) with a specific operation code:

Operation OP_CODE

OP_CACHE_GET

1000

OP_CACHE_PUT

1001

OP_CACHE_PUT_IF_ABSENT

1002

OP_CACHE_GET_ALL

1003

OP_CACHE_PUT_ALL

1004

OP_CACHE_GET_AND_PUT

1005

OP_CACHE_GET_AND_REPLACE

1006

OP_CACHE_GET_AND_REMOVE

1007

OP_CACHE_GET_AND_PUT_IF_ABSENT

1008

OP_CACHE_REPLACE

1009

OP_CACHE_REPLACE_IF_EQUALS

1010

OP_CACHE_CONTAINS_KEY

1011

OP_CACHE_CONTAINS_KEYS

1012

OP_CACHE_CLEAR

1013

OP_CACHE_CLEAR_KEY

1014

OP_CACHE_CLEAR_KEYS

1015

OP_CACHE_REMOVE_KEY

1016

OP_CACHE_REMOVE_IF_EQUALS

1017

OP_CACHE_REMOVE_KEYS

1018

OP_CACHE_REMOVE_ALL

1019

OP_CACHE_GET_SIZE

1020

Note that the above mentioned op_codes are part of the request header, as explained here.

Note

Customs Methods Used in Sample Code Snippets Implementation

Some of the code snippets below use readDataObject(…​) introduced in this section and little-endian versions of methods for reading and writing multiple-byte values that are covered in this example.

OP_CACHE_GET

Retrieves a value from a cache by key. If the cache does not contain the key, null is returned.

Request Type Description

Header

Request header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

The key of the cache entry to be returned.

Response Type Description

Header

Response header.

Data Object

The value that corresponds to the given key. null if the cache does not contain the key.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());


// Request header
writeRequestHeader(10, OP_CACHE_GET, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting cache value (Data Object)
int resTypeCode = readByteLittleEndian(in);
int value = readIntLittleEndian(in);

OP_CACHE_GET_ALL

Retrieves multiple key-value pairs from a cache.

Request Type Description

Header

Request header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

int

Key count.

Data Object

Key for the cache entry.

Repeat for as many times as the key count that is passed in the previous parameter.

Response Type Description

Header

Response header.

int

Result count.

Key Data Object + Value Data Object

Resulting key-value pairs. Keys that are not present in the cache are not included.

Repeat for as many times as the result count that is obtained in the previous parameter.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(19, OP_CACHE_GET_ALL, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Key count
writeIntLittleEndian(2, out);

// Data object 1
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key1, out);   // Cache key

// Data object 2
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key2, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Result count
int resCount = readIntLittleEndian(in);

for (int i = 0; i < resCount; i++) {
  // Resulting data object
  int resKeyTypeCode = readByteLittleEndian(in); // Integer type code
  int resKey = readIntLittleEndian(in); // Cache key

  // Resulting data object
  int resValTypeCode = readByteLittleEndian(in); // Integer type code
  int resValue = readIntLittleEndian(in); // Cache value
}

OP_CACHE_PUT

Puts a value with a given key to a cache (overwriting existing value if any).

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

Key for the cache entry.

Data Object

Value for the key.

Response Type Description

Header

Response Header

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(15, OP_CACHE_PUT, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value, out);   // Cache value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

OP_CACHE_PUT_ALL

Puts multiple key-value pairs to cache (overwriting existing associations if any).

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

int

Key-value pair count

Key Data Object + Value Data

Object Key-value pairs.

Repeat for as many times as the key-value pair count that is passed in the previous parameter.

Response Type Description

Header

Response header.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(29, OP_CACHE_PUT_ALL, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Entry Count
writeIntLittleEndian(2, out);

// Cache key data object 1
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key1, out);   // Cache key

// Cache value data object 1
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value1, out);   // Cache value

// Cache key data object 2
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key2, out);   // Cache key

// Cache value data object 2
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value2, out);   // Cache value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

OP_CACHE_CONTAINS_KEY

Returns a value indicating whether given key is present in cache.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

Key for the cache entry.

Response Type Description

Header

Response header.

bool

True when key is present, false otherwise.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(10, OP_CACHE_CONTAINS_KEY, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Result
boolean res = readBooleanLittleEndian(in);

OP_CACHE_CONTAINS_KEYS

Returns a value indicating whether all given keys are present in cache.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

int

Key count.

Data Object

Key obtained from cache.

Repeat for as many times as the key count that is passed in the previous parameter.

Response Type Description

Header

Response header.

bool

True when keys are present, false otherwise.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(19, OP_CACHE_CONTAINS_KEYS, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

//Count
writeIntLittleEndian(2, out);

// Cache key data object 1
int key1 = 11;
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key1, out);   // Cache key

// Cache key data object 2
int key2 = 22;
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key2, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting boolean value
boolean res = readBooleanLittleEndian(in);

OP_CACHE_GET_AND_PUT

Puts a key and an associated value into a cache and returns the previous value for that key. If the cache does not contain the key, a new entry is created and null is returned.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

The key to be updated.

Data Object

The new value for the specified key.

Response Type Description

Header

Response header.

Data Object

The existing value associated with the specified key, or null.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(15, OP_CACHE_GET_AND_PUT, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value, out);   // Cache value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting cache value (Data Object)
int resTypeCode = readByteLittleEndian(in);
int value = readIntLittleEndian(in);

OP_CACHE_GET_AND_REPLACE

Replaces the value associated with the given key in the specified cache and returns the previous value. If the cache does not contain the key, the operation returns null without changing the cache.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

The key whose value is to be replaced.

Data Object

The new value to be associated with the specified key.

Response Type Description

Header

Response header.

Data Object

The previous value associated with the given key, or null if the key does not exist.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(15, OP_CACHE_GET_AND_REPLACE, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value, out);   // Cache value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting cache value (Data Object)
int resTypeCode = readByteLittleEndian(in);
int value = readIntLittleEndian(in);

OP_CACHE_GET_AND_REMOVE

Removes a specific entry from a cache and returns the entry’s value. If the key does not exist, null is returned.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

The key to be removed.

Response Type Description

Header

Response header.

Data Object

The existing value associated with the specified key or null, if the key does not exist.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(10, OP_CACHE_GET_AND_REMOVE, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting cache value (Data Object)
int resTypeCode = readByte(in);
int value = readInt(in);

OP_CACHE_PUT_IF_ABSENT

Puts an entry to a cache if that entry does not exist.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

The key of the entry to be added.

Data Object

The value of the key to be added.

Response Type Description

Header

Response header.

bool

true if the new entry is created, false if the entry already exists.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(15, OP_CACHE_PUT_IF_ABSENT, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value, out);   // Cache Value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting boolean value
boolean res = readBooleanLittleEndian(in);

OP_CACHE_GET_AND_PUT_IF_ABSENT

Puts an entry to a cache if it does not exist; otherwise, returns the existing value.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

The key of the entry to be added.

Data Object

The value of the entry to be added.

Response Type Description

Header

Response header.

Data Object

null if the cache does not contain the entry (in this case a new entry is created) or the existing value associated with the given key.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(15, OP_CACHE_GET_AND_PUT_IF_ABSENT, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value, out);   // Cache value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting cache value (Data Object)
int resTypeCode = readByteLittleEndian(in);
int value = readIntLittleEndian(in);

OP_CACHE_REPLACE

Puts a value with a given key to cache only if the key already exists.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

Key for the cache entry.

Data Object

Value for the key.

Response Type Description

Header

Response header.

bool

Value indicating whether replace happened.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(15, OP_CACHE_REPLACE, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value, out);   // Cache value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

boolean res = readBooleanLittleEndian(in);

OP_CACHE_REPLACE_IF_EQUALS

Puts a value with a given key to cache only if the key already exists and value equals provided value.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

Key for the cache entry.

Data Object

Value to be compared with the existing value in the cache for the given key.

Data Object

New value for the key.

Response Type Description

Header

Response header.

bool

Value indicating whether replace happened.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(20, OP_CACHE_REPLACE_IF_EQUALS, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value, out);   // Cache value to compare

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(newValue, out);   // New cache value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

boolean res = readBooleanLittleEndian(in);

OP_CACHE_CLEAR

Clears the cache without notifying listeners or cache writers. See the javadoc for the corresponding cache method.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Response Type Description

Header

Response header.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(5, OP_CACHE_CLEAR, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

OP_CACHE_CLEAR_KEY

Clears the cache key without notifying listeners or cache writers. See the javadoc for the corresponding cache method.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

Key for the cache entry.

Response Type Description

Header

Response header.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(10, OP_CACHE_CLEAR_KEY, 1, out);;

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

OP_CACHE_CLEAR_KEYS

Clears the cache keys without notifying listeners or cache writers. See the javadoc for the corresponding cache method.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

int

Key count.

Data Object * count

Keys

Response Type Description

Header

Response header.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(19, OP_CACHE_CLEAR_KEYS, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// key count
writeIntLittleEndian(2, out);

// Cache key data object 1
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key1, out);   // Cache key

// Cache key data object 2
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key2, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

OP_CACHE_REMOVE_KEY

Removes an entry with a given key, notifying listeners and cache writers. See the javadoc for the corresponding cache method.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

Key for the cache entry.

Response Type Description

Header

Response header.

bool

Value indicating whether remove happened.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(10, OP_CACHE_REMOVE_KEY, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key1, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting boolean value
boolean res = readBooleanLittleEndian(in);

OP_CACHE_REMOVE_IF_EQUALS

Removes an entry with a given key if the specified value is equal to the current value, notifying listeners and cache writers.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Data Object

The key of the entry to be removed.

Data Object

The value to be compared with the current value.

Response Type Description

Header

Response header.

bool

Value indicating whether remove happened

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(15, OP_CACHE_REMOVE_IF_EQUALS, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Cache key data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key, out);   // Cache key

// Cache value data object
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(value, out);   // Cache value
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Resulting boolean value
boolean res = readBooleanLittleEndian(in);

OP_CACHE_GET_SIZE

Gets the number of entries in a cache. This method is equivalent to IgniteCache.size(CachePeekMode…​ peekModes).

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

int

The number of peek modes you are going to request. When set to 0, CachePeekMode.ALL is used. When set to a positive value, you need to specify in the following fields the type of entries that should be counted: all, backup, primary, or near cache entries.

byte

Indicates which type of entries should be counted: 0 = all, 1 = near cache entries, 2 = primary entries, 3 = backup entries.

This field must be provided as many times as specified in the previous field.

Response Type Description

Header

Response header.

long

Cache size.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(10, OP_CACHE_GET_SIZE, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// Peek mode count; '0' means All
writeIntLittleEndian(0, out);

// Peek mode
writeByteLittleEndian(0, out);
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

// Number of entries in cache
long cacheSize = readLongLittleEndian(in);

OP_CACHE_REMOVE_KEYS

Removes entries with given keys, notifying listeners and cache writers. See the javadoc for the corresponding cache method.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

int

Number of keys to remove.

Data Object

The key to be removed. If the cache does not contain the key, it is ignored. This field must be provided for each key to be removed.

…​.

Data Object

The key to be removed.

Response Type Description Header
DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(19, OP_CACHE_REMOVE_KEYS, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);

// key count
writeIntLittleEndian(2, out);

// Cache key data object 1
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key1, out);   // Cache key

// Cache value data object 2
writeByteLittleEndian(3, out);  // Integer type code
writeIntLittleEndian(key2, out);   // Cache key
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response header
readResponseHeader(in);

OP_CACHE_REMOVE_ALL

Removes all entries from cache, notifying listeners and cache writers. See the javadoc for the corresponding cache method.

Request Type Description

Header

Request Header.

int

Cache ID: Java-style hash code of the cache name.

byte

Use 0. This field is deprecated and will be removed in the future.

Response Type Description

Header

Response header.

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Request header
writeRequestHeader(5, OP_CACHE_REMOVE_ALL, 1, out);

// Cache id
writeIntLittleEndian(cacheName.hashCode(), out);

// Flags = none
writeByteLittleEndian(0, out);
// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response length
final int len = readIntLittleEndian(in);

// Request id
long resReqId = readLongLittleEndian(in);

// Success
int statusCode = readIntLittleEndian(in);