package client;
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
public class MapSample {
public static void main(String[] args) {
// Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
HazelcastInstance hz = HazelcastClient.newHazelcastClient();
// Get the Distributed Map from Cluster.
IMap map = hz.getMap("my-distributed-map");
//Standard Put and Get.
map.put("key", "value");
map.get("key");
//Concurrent Map methods, optimistic updating
map.putIfAbsent("somekey", "somevalue");
map.replace("key", "value", "newvalue");
// Shutdown this Hazelcast client
hz.shutdown();
}
}
using Hazelcast.Client;
namespace Hazelcast.Examples.Org.Website.Samples
{
public class MapSample
{
public static void Run(string[] args)
{
// Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
var hz = HazelcastClient.NewHazelcastClient();
// Get the Distributed Map from Cluster.
var map = hz.GetMap("my-distributed-map");
//Standard Put and Get.
map.Put("key", "value");
map.Get("key");
//Concurrent Map methods, optimistic updating
map.PutIfAbsent("somekey", "somevalue");
map.Replace("key", "value", "newvalue");
// Shutdown this Hazelcast Client
hz.Shutdown();
}
}
}
#include
using namespace hazelcast::client;
int main() {
// Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
HazelcastClient hz;
// Get the Distributed Map from Cluster.
IMap map = hz.getMap("my-distributed-map");
//Standard Put and Get.
map.put("key", "value");
map.get("key");
//Concurrent Map methods, optimistic updating
map.putIfAbsent("somekey", "somevalue");
map.replace("key", "value", "newvalue");
// Shutdown this Hazelcast Client
hz.shutdown();
return 0;
}
var Client = require('hazelcast-client').Client;
// Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
Client.newHazelcastClient().then(function (hz) {
var map;
// Get the Distributed Map from Cluster.
hz.getMap('my-distributed-map').then(function (mp) {
map = mp;
// Standard Put and Get.
return map.put('key', 'value');
}).then(function () {
return map.get('key');
}).then(function (val) {
// Concurrent Map methods, optimistic updating
return map.putIfAbsent('somekey', 'somevalue');
}).then(function () {
return map.replace('key', 'value', 'newvalue');
}).then(function (value) {
// Shutdown this Hazelcast client
hz.shutdown();
});
});
import hazelcast
if __name__ == "__main__":
# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
hz = hazelcast.HazelcastClient()
# Get the Distributed Map from Cluster.
map = hz.get_map("my-distributed-map").blocking()
# Standard Put and Get
map.put("key", "value")
map.get("key")
# Concurrent Map methods, optimistic updating
map.put_if_absent("somekey", "somevalue")
map.replace_if_same("key", "value", "newvalue")
# Shutdown this Hazelcast Client
hz.shutdown()
package orgwebsite
import "github.com/hazelcast/hazelcast-go-client"
func mapSampleRun() {
// Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
hz, _ := hazelcast.NewClient()
// Get the Distributed Map from Cluster.
mp, _ := hz.GetMap("myDistributedMap")
//Standard Put and Get.
mp.Put("key", "value")
mp.Get("key")
//Concurrent Map methods, optimistic updating
mp.PutIfAbsent("somekey", "somevalue")
mp.ReplaceIfSame("key", "value", "newvalue")
// Shutdown this hazelcast client
hz.Shutdown()
}