Coherence JavaScript Client is Available!

Randy Stafford
Oracle Coherence
Published in
2 min readSep 3, 2020

--

Have you ever wanted fast, scalable key-value storage for JavaScript objects from a Node.js application? Now you can have it with the Coherence JavaScript Client and Coherence Community Edition release 20.06.1.

Coherence JavaScript Client offers the familiar Map interface to get and set keyed values, and a whole lot more:

  • querying Map values by criteria
  • aggregating values in a Map
  • in-place processing of Map entries
  • listening for Map events

Here’s a quick code example showing the basics:

const { Session } = require('@oracle/coherence')let session = new Session()
let map = session.getMap('Test')
setImmediate(async () => {
console.log("Map size is " + (await map.size))
console.log("Inserting entry (key=1, value=One)")
await map.set(1, "One")
console.log("Map entry is " + (await map.get(1)))
console.log("Deleting entry (key=1)")
await map.delete(1)
console.log("Map size is " + (await map.size))
await session.close()
})

When run, it produces:

Map size is 0
Inserting entry (key=1, value=One)
Map entry is One
Deleting entry (key=1)
Map size is 0

Here’s another example, showing queries over JSON objects:

await map.set('0001', {name: "Bill Smith", age: 38, hobbies: ["gardening", "painting"]})
await map.set('0002', {name: "Fred Jones", age: 56, hobbies: ["racing", "golf"]})
await map.set('0003', {name: "Jane Doe", age: 48, hobbies: ["gardening", "photography"]})

Using a filter we can limit the result set returned by the map:

const { Filters } = require('@oracle/coherence')
...
await
map.entries(Filters.greater('age', 40))
// [{key: '0002', value: {name: "Fred Jones"...}}, {key: '0002', value: {name: "Jane Doe"...}}]
await map.keys(Filters.arrayContains('hobbies', 'gardening'))
// ['0001', '0003']
await map.values(Filters.not(Filters.arrayContains('hobbies', 'gardening')))
// [{name: "Fred Jones", age: 56, hobbies: ["racing", "golf"]}]

Coherence JavaScript Client uses the recently released gRPC proxy from the open-source Coherence Community Edition to communicate with a remote Coherence cluster from a Node.js process. The remote Coherence cluster is capable of storing terabytes of data persistently, and handling thousands of operations per second. Data is sharded automatically in the cluster, which can be dynamically scaled and operated with Kubernetes.

Coherence JavaScript Client is the second native-language client (after Java) to use the new gRPC proxy in Coherence, with many more to come. New implementations of the .NET and C++ clients currently based on the Coherence*Extend proxy are in the pipeline, as are Python and mobile platform clients.

If you have a Node.js application needing highly scalable and reliable key-value data management, including querying and eventing, then have a look at Coherence Community Edition and Coherence JavaScript Client.

More information may be found at the following links:

--

--