Skip to content

Instantly share code, notes, and snippets.

@brunoborges
Created August 10, 2014 14:49
Show Gist options
  • Save brunoborges/a7244d9439fcc505ba25 to your computer and use it in GitHub Desktop.
Save brunoborges/a7244d9439fcc505ba25 to your computer and use it in GitHub Desktop.
if (arguments.length != 2) {
print("Usage: jjs -cp lib/kvclient.jar oracle-nosql-put.js -- <key> <value>");
exit(1);
}
var oracle = Packages.oracle;
var KVStore = oracle.kv.KVStore;
var KVStoreConfig = oracle.kv.KVStoreConfig;
var KVStoreFactory = oracle.kv.KVStoreFactory;
var store = KVStoreFactory.getStore(new KVStoreConfig("kvstore", "localhost:5000"));
var nosqlPkg = new JavaImporter(oracle.kv);
with(nosqlPkg) {
var key = Key.createKey(arguments[0].toString());
var value = Value.createValue(arguments[1].toString().getBytes("UTF-8"));
store.put(key, value);
store.close();
print("key inserted/updated!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment