ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivasilin...@apache.org
Subject [2/2] incubator-ignite git commit: #ignite-964: put-get-example.
Date Mon, 06 Jul 2015 15:31:11 GMT
#ignite-964: put-get-example.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c8af45dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c8af45dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c8af45dc

Branch: refs/heads/ignite-964-1
Commit: c8af45dc9cabe30de76918bc9ad8278704db3510
Parents: ca75428
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Mon Jul 6 18:30:52 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Mon Jul 6 18:30:52 2015 +0300

----------------------------------------------------------------------
 .../js/examples/src/cache-put-get-example.js    | 41 ++++++++++++++++++++
 1 file changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c8af45dc/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js b/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js
index 099721f..d6b65d8 100644
--- a/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js
+++ b/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js
@@ -18,6 +18,7 @@
 var Ignite = require("../../");
 
 var Ignition = Ignite.Ignition;
+var Entry = Ignite.Entry;
 
 Ignition.start(['127.0.0.1:9095'], null, onConnect);
 
@@ -32,6 +33,8 @@ function onConnect(error, ignite) {
 
     putGet(cache);
 
+    putAllGetAll(cache);
+
 }
 
 putGet = function(cache) {
@@ -76,5 +79,43 @@ putGet = function(cache) {
 }
 
 putAllGetAll = function(cache) {
+    console.log(">>> Starting putAll-getAll example.");
+
+    var keyCnt = 20;
+
+    var batch = [];
+    var keys = [];
+
+    for (var i = keyCnt; i < keyCnt + keyCnt; ++i) {
+        var key = i;
+
+        var val = "bulk-" + i;
+
+        keys.push(key);
+        batch.push(new Entry(key, val));
+    }
+
+    var onGetAll = function(err, entries) {
+        if (err) {
+            console.log("Error: " + err);
+
+            throw new Error(err);
+        }
+
+        for (var e of entries) {
+            console.log("Got entry [key=" + e.key + ", val=" + e.value + ']');
+        }
+    }
+
+    var onPutAll= function(err) {
+        if (err) {
+            console.log("Error: " + err);
+
+            throw new Error(err);
+        }
+
+        cache.getAll(keys, onGetAll);
+    }
 
+    cache.putAll(batch, onPutAll);
 }
\ No newline at end of file


Mime
View raw message