You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/08 18:36:34 UTC

incubator-ignite git commit: #ignite-961: add removeAll method to node js cache.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-961 4fa7cd8df -> fb197cd35


#ignite-961: add removeAll method to node js cache.


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

Branch: refs/heads/ignite-961
Commit: fb197cd35bc4c1c10dd5f6ee0de272eb8877d4fb
Parents: 4fa7cd8
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jun 8 19:36:26 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jun 8 19:36:26 2015 +0300

----------------------------------------------------------------------
 modules/nodejs/src/main/js/cache.js               | 16 ++++++++++++++++
 .../ignite/internal/NodeJsCacheApiSelfTest.java   |  7 +++++++
 modules/nodejs/src/test/js/test-cache-api.js      | 18 ++++++++++++++++++
 3 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fb197cd3/modules/nodejs/src/main/js/cache.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/cache.js b/modules/nodejs/src/main/js/cache.js
index b3f698a..fe46406 100644
--- a/modules/nodejs/src/main/js/cache.js
+++ b/modules/nodejs/src/main/js/cache.js
@@ -78,4 +78,20 @@ Cache.prototype.remove = function(key, callback) {
   this._server.runCommand("rmv", [this._cacheNameParam, Server.pair("key", key)], callback);
 }
 
+/**
+ * Remove cache keys
+ *
+ * @param {string[]} keys Keys to remove
+ * @param {noValue} callback Called on finish
+ */
+Cache.prototype.removeAll = function(keys, callback) {
+  var params = [this._cacheNameParam];
+
+  for (var i = 0; i < keys.length; ++i) {
+    params.push(Server.pair("k" + i, keys[i]));
+  }
+
+  this._server.runCommand("rmvall", params, callback);
+}
+
 exports.Cache = Cache
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fb197cd3/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java
index 13746cb..2f64219 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java
@@ -70,4 +70,11 @@ public class NodeJsCacheApiSelfTest extends NodeJsAbstractTest {
     public void testRemoveNoKey() throws Exception {
         runJsScript("testRemoveNoKey");
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRemoveAll() throws Exception {
+        runJsScript("testRemoveAll");
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fb197cd3/modules/nodejs/src/test/js/test-cache-api.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-cache-api.js b/modules/nodejs/src/test/js/test-cache-api.js
index 6a00a62..c5fe1da 100644
--- a/modules/nodejs/src/test/js/test-cache-api.js
+++ b/modules/nodejs/src/test/js/test-cache-api.js
@@ -39,6 +39,10 @@ testRemoveNoKey = function() {
   TestUtils.startIgniteNode(onStartRemove.bind(null, onRemove, "mycache"));
 }
 
+testRemoveAll = function() {
+  TestUtils.startIgniteNode(onStart.bind(null, onPutRemoveAll, "mycache"));
+}
+
 function onStart(onPut1, cacheName, error, ignite) {
   var cache = ignite.cache(cacheName);
 
@@ -57,6 +61,20 @@ function onPutRemove(cache, error) {
   cache.get("key", onGetRemove.bind(null, cache));
 }
 
+function onPutRemoveAll(cache, error) {
+  assert(error == null);
+
+  cache.get("key", onGetRemoveAll.bind(null, cache));
+}
+
+function onGetRemoveAll(cache, error, value) {
+  assert(error == null);
+
+  assert(value == 6);
+
+  cache.removeAll(["key"], onRemove.bind(null, cache));
+}
+
 function onGetRemove(cache, error, value) {
   assert(error == null);