THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Response | |
BinaryObject | Existing value for the specified key, or null |
TODO: Other operations
LetAs an example let's see how request and response would look for a cache.get operation for integer key and value:TODOto connect to Ignite instance on a local machine and retrieve an int value for a given int key, in pseudocode.
Code Block |
---|
var socket = openSocket("127.0.0.1:10800");
// Message length
socket.writeInt(8);
// Handshake operation
socket.writeByte(1);
// Protocol version 1.0.0
socket.writeShort(1);
socket.writeShort(0);
socket.writeShort(0);
// Client type: thin client
socket.writeByte(2);
// Receive result
var resLen = socket.readInt();
assert resLen == 1; // Success message length is 1
var res = socket.readByte();
assert res == 1; // Success code
// END HANDSHAKE
// Perform OP_CACHE_GET
// Message length
socket.writeInt(20)
// Op code = OP_CACHE_GET
socket.writeShort(1);
// Request id (can be anything; does not matter for simple blocking socket IO)
var reqId = 1;
socket.writeLong(reqId);
// Cache id
var cacheName = "myCache";
var cacheId = javaHashCode(cacheName);
socket.writeInt(cacheId);
// Flags = none
socket.writeByte(0);
// Cache key
socket.writeByte(3); // Integer type code
socket.writeInt(1); // Our cache value
// Read result
var len = socket.readInt();
assert len == 17; // requestId (8) + status code (4) + int object (1 + 4)
var resReqId = socket.readLong();
assert reqId == resReqId;
var statusCode = socket.readInt();
assert statusCode == 0; // Success
var resTypeCode = socket.readByte();
assert restypeCode == 3; // Integer
var res = socket.readInt();
print(res); // Resulting cache value |
...