Node.js apps that interact with a Node.js Client for VMware GemFire cluster are the clients within a client/server model. The VMware GemFire cluster contains the servers.
A best practice is to first develop in a local envirornment, followed by deployment and testing with a Cloud Cache service instance. Read about the environments in The Development Environment.
All apps must implement a set of intialization steps. See App Initialization Steps for details.
Example code is available at https://github.com/gemfire/node-examples. Each example has a README
file that briefly explains what the example demonstrates and how to run the example. The CRUD-ops
example presents introductory code to get started using the Node.js Client. CRUD Operations describes the example and introduces the operations.
Many API methods return a Javascript promise; these methods execute asynchronously and resolve to a value when complete. This implementation is intentional. All method invocations that may result in an extra network hop while executing are defined to return a promise.
To capture the resolved value from a method that returns a promise, use a Javascript await
. For example, the region.get(key)
function returns a promise that resolves to the entry’s value for the given key. The value will be assigned once the promise resolves when using await
, as in the example code fragment:
value = await region.get(CustomerId)
// code here that uses value
Or, the code may be written as:
region.get(CustomerId)
.then(value => {
// code here that uses value
})
.catch(err => {
// code here that handles errors
});