version 2.0
Cache
methods facilitate interaction with the servers. A Cache
object is used to instantiate and get a Region
.
Terminate this cache and release all local resources.
After this cache is closed, any further method call on this cache, or on any object associated with this cache, will throw CacheClosedException
.
Node.js apps should always call close()
on a cache instance when it is no longer used in order to prevent leaks of resources
(such as memory and N-API handles) that can occur in the Node.js environment.
Promise
:
a Promise that resolves to empty on success.
const gemfire = require('gemfire')
cache = gemfire.createCacheFactory('./gfcpp.properties', 'xml/ExampleClient.xml')
.create()
// Do things with the cache here
await cache.close()
Instantiates a region in the app.
See [Region Attributes]https://gemfire-native.docs.pivotal.io/latest/geode-native-client/regions/region-attributes.html for descriptions of the region types.
(string)
is a string that identifies the region.
(object)
is an object that contains region details. The
configuration
contains at a minimum the region type property, also known as a region shortcut. A
poolName
property may also be set.
Valid region type property values are
type: 'PROXY'
type: 'CACHING_PROXY'
Region
:
a Region object. Returns an error when called with no arguments, when
regionName
is not a string, when no
configuration
object is passed, when the
configuration
object has no type property, or when the type property is not a valid region type.
const gemfire = require('gemfire')
cache = await gemfire.createCacheFactory('./gfcpp.properties', 'xml/ExampleClient.xml')
.create()
cache.getPoolManager()
.createPoolFactory()
.addLocator('localhost', 10334)
.create('examplePool')
region = cache.createRegion('exampleRegion', { type: 'PROXY', poolName: 'examplePool' })
// Do things with the region here, e.g. put/get some values
await cache.close()
Invokes a data-independent function which has already been deployed on the server. See Region.executeFunction for data-dependent functions
(string)
is the name of the function to be executed.
(object)
is an object that contains two properties:
args
: an object that contains the arguments for the function.target
: a string that is either 'onServer'
to run the function on the server attached to the cache or 'onServers'
to run the function on all the servers.Promise<Array<any>>
:
a Promise that resolves to an array containing the results from the function's execution. Returns an error when:
options
is not an object.functionName
is undefined
.args
is given a function.functionName
is not found on the server.functionName
throws an error on the server.functionName
sends an exception with its results.var sum = cache.executeFunction('io.pivotal.node_gemfire.Sum', { args: [1, 2, 3] })
// Should print '6'
console.log('Sum of [1, 2, 3] is ' + sum[0])
Retrieves all values that match the query.
(string)
is the string representation of a query. See
Querying With OQL
from the GemFire docs for details of supported OQL syntax.
Promise<Array<any>>
:
a Promise that resolves to an array of values. Returns an error when no arguments are passed, when too many arguments are passed, when
queryString
is not a string, and when
queryString
is an invalid query.
await region.put('a string', 'a string')
const queryResults = await cache.executeQueryOnDefaultPool('SELECT DISTINCT * FROM /exampleRegion')
console.log(queryResults.length)
console.log('key: "a string", value: ' + queryResults[0])
// output:
// key: "a string", value: this is a string
Acquires the pool manager from the cache. The PoolManager is required in order to create PoolFactory objects, and ultimately new Pools.
PoolManager
:
The pool manager.
// code example here for getPoolManager()
const gemfire = require('gemfire')
cache = await gemfire.createCacheFactory('./gfcpp.properties', 'xml/ExampleClient.xml')
.create()
poolManager = cache.getPoolManager()
// Do things with the pool manager here, usually just create a PoolFactory
await cache.close()
Returns a region object for the specified client region.
(string)
is a string that identifies the region.
Region
:
Returns the region object. Returns
undefined
if there is no region identified as
regionName
.
const gemfire = require('gemfire')
cache = await gemfire.createCacheFactory('./gfcpp.properties', 'xml/ExampleClient.xml')
.create()
region = cache.getRegion('exampleRegion')
// Do things with the region here, e.g. put/get some values
await cache.close()
This is a top level object for configuring GemFire on a client.
Use CacheFactory.create()
to create a Cache
object.
Set a GemFire property that will be honored when creating a cache.
(string)
is the name of the GemFire property.
(any)
is the value of the GemFire property.
CacheFactory
:
the updated
CacheFactory
object. Returns an error when the incorrect number of arguments are passed.
const gemfire = require('gemfire')
factory = gemfire.createCacheFactory('./gfcpp.properties', 'xml/ExampleClient.xml')
// Send logs to a file, customize file/location here
factory.set('log-file', 'cacheFactorySetExample.log')
Set authentication properties for use when setting up communication with servers.
(function (properties, server))
is function that has two parameters,
properties
and
server
.
properties
is a dictionary that maps property names to their values.
server
is a string indicating the current endpoint, of the form "host:port".
(function ())
is a callback function with no parameters that is invoked when
setAuthentication
completes.
CacheFactory
:
the updated
CacheFactory
object.
cacheFactory.setAuthentication((properties, server) => {
properties['security-username'] = 'root'
properties['security-password'] = 'root-password'
}, () => {
})
Controls when PDX serialization ignores fields that were unread during deserialization.
(boolean)
is a boolean that, when
true
, causes fields not read to be ignored, and when
false
, causes the fields to be preserved even if not read. The default value is
false
.
CacheFactory
:
the updated
CacheFactory
object.
const gemfire = require('gemfire')
factory = gemfire.createCacheFactory('./gfcpp.properties', 'xml/ExampleClient.xml')
factory.setPdxIgnoreUnreadFields(true)
The gemfire
nodejs module provides the global entry point into the GemFire API.
To make use of the API, an application must create a gemfire object by using
require("gemfire").
Instantiates a default CacheFactory. There are two variants to this api - the first just assumes all of the GemFire defaults for any properties. The second allows the developer to externalize some of the properties and cache configuration in separate files.
CacheFactory
:
a default CacheFactory object which must be configured programmatically.
const gemfire = require('gemfire')
cacheFactory = await gemfire.createCacheFactory()
Instantiates a CacheFactory configured through a properties file and a cache.xml file.
(string)
is a path to a file containing system properties. A variety of system properties can be specified when a client connects to a distributed system, either programmatically or using this systemPropertiesFile.
For more information see
https://gemfire-native.docs.pivotal.io/100/geode-native-client/configuring/sysprops.html
(string)
is a path to a file containing cache configuration, typically referred to as cache.xml. The declarative XML file is used to externalize the configuration of the client cache.
For more information see
https://gemfire-native.docs.pivotal.io/100/geode-native-client/client-cache-ref.html
CacheFactory
:
a CacheFactory object.
const gemfire = require('gemfire')
cacheFactory = await gemfire.createCacheFactory('./system.properties', 'ExampleClient.xml')
A Pool
object represents a set of connections between the client and a set of servers.
Closes any connections and removes the pool object.
(boolean)
is a boolean that, when true, keeps client subscriptions alive during the timeout period, and when false, does not keep the subscriptions alive.
undefined
:
expect(pool.isDestroyed()).toBeFalse()
pool.destroy(true)
expect(pool.isDestroyed()).toBeTrue()
Invokes a data-independent function which has already been deployed on the servers of a specific pool. This method permits an app to execute data-independent functions on more than one pool.
(string)
is the name of the function to execute
(string)
, must be either "onServer", i.e. execute on a single server, or "onServers",
i.e. on all servers in the cluster.
(object?)
, the arguments accepted by your function. Structure of this object may vary,
depending on the needs of the function.
Name | Description |
---|---|
args.0 any
|
Promise<Array<any>>
:
a Promise that resolves to an array containing the results from the function’s execution. Returns an error when:
const data = await pool.executeFunction('io.pivotal.node_gemfire.Sum', { args: [1, 2, 3] })
expect(data).toEqual([6])
Gets the load conditioning interval for this pool. This interval controls how frequently the pool will check to see if a connection to a given server should be moved to a different server to improve the load balance.
number
:
returns the timeout in milliseconds.
Gets the minimum number of connections for this pool. If the value is 0, then connections will not be made until an operation is invoked that requires client-to-server communication.
number
:
returns the minimum number of connections which will be created for this pool.
Gets the ping interval, the frequency at which a client must ping each server to verify that the client is still alive. These pings are used by the server to monitor the health of the client. Make sure that the pingInterval is less than the maximum time between pings allowed by the server.
number
:
Returns the interval in milliseconds.
Gets current value of PR Single Hop Enabled.
When set to true
, restrict server to server hops when performing put, get, and destroy
operations on partitioned regions, to maximize performance. The client will make requests to
the server containing the primary copy of the data entries it needs.
boolean
:
Returns
true
if PR Single Hop is enabled.
If this pool was configured to use thread local connections, then this method will release the connection cached for the calling thread. The connection will then be available for use by other threads. If this pool is not using thread local connections, this method will have no effect.
undefined
:
Returns
undefined
.
Facilitates the configuration and creation of a Pool
object.
Default values used when creating a Pool
:
Property | Type | Default |
---|---|---|
FreeConnectionTimeout | number (milliseconds) | 10000 |
IdleTimeout | number (milliseconds) | 5000 |
LoadConditioningInterval | number (milliseconds) | 300000 |
MaxConnections | number | -1 (unlimited) |
MinConnections | number | 1 |
MultiuserAuthentication | boolean | false |
PingInterval | number (milliseconds) | 10000 |
PRSingleHopEnabled | boolean | true |
ReadTimeout | number (milliseconds) | 10000 |
RetryAttempts | number | -1 (unlimited) |
ServerGroup | string | '' (all servers) |
SocketBufferSize | number | 32768 |
StatisticInterval | number (milliseconds) | 0 (disabled) |
SubscriptionAckInterval | number (milliseconds) | 100 |
SubscriptionEnabled | boolean | true |
SubscriptionMessageTrackingTimeout | number (milliseconds) | 900000 |
SubscriptionRedundancy | number | 0 |
ThreadLocalConnections | boolean | false |
UpdateLocatorListInterval | number (milliseconds) | 5000 |
Adds a locator to the list of locators used when creating a pool.
(string)
is a string representing a locator's DNS name or IP address.
(string)
is an integer representing the port that the locator listens on.
PoolFactory
:
the updated
PoolFactory
. Returns an error when
locatorAddress
is not a string, when
locatorPort
is not a number, when too many arguments are given, or when not enough arguments are given.
cacheFactory.create()
.then((cache) => {
const poolFactory = cache.getPoolManager().createFactory()
poolFactory.addLocator(locatorServer, locatorPort)
}
Adds a server to the list of servers used when creating a pool.
(string)
is a string representing a server's DNS name or IP address.
(string)
is an integer representing the port that the server listens on.
PoolFactory
:
the updated
PoolFactory
. Returns an error when
serverAddress
is not a string, when
serverAddress
is not a number, when too many arguments are given, or when not enough arguments are given.
cacheFactory.create()
.then((cache) => {
const poolFactory = cache.getPoolManager().createFactory()
poolFactory.addServer('localhost', 40404)
}
Creates a pool with the given name.
(string)
is a string that identifies the pool.
Pool
:
Returns a Pool. Returns an error when
poolName
is not provided.
cacheFactory.create()
.then((cache) => {
const poolFactory = cache.getPoolManager().createFactory()
poolFactory.addLocator(locatorServer, locatorPort)
poolFactory.create('myPool')
}
Sets the free connection timeout for a pool. The free connection timeout specifies how long those operations will block when waiting for a free connection.
(number)
is the number of milliseconds for the timeout.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when too many arguments are given, or no arguments are provided.
Set the idle timeout for a pool. If the pool size is greater than the minimum specified by PoolFactory.setMinConnections(connections)
, connections which have been idle for longer than the milliseconds
will be closed.
(number)
is the number of milliseconds for the timeout.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when too many arguments are given, or when no argument is provided.
Sets the load conditioning interval for a pool. This interval controls how frequently the pool will check to see if a connection to a given server should be moved to a different server to improve the load balance.
(number)
is the number of milliseconds for the interval.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when too many arguments are given, or when no argument is provided.
Sets the maxium number of connections for a pool. A value of -1 indicates that there is no maximum number of connections.
(number)
is the maximum number of connections.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
connections
is not a number, when too many arguments are given, or when no argument is provided.
Sets the minimum number of connections for a pool. A value of 0 causes connections to be delayed until an operation is invoked that requires client-to-server communication.
(number)
is the minimum number of connections.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
connections
is not a number, when
connections
is less than zero, when too many arguments are given, or when no argument is provided.
Configure if a pool can use multiuser authentication secure mode.
(boolean)
is a boolean that is
true
when multiuser authentication secure mode is enabled.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
multiuserAuth
is not a boolean, when too many arguments are given, or when no argument is provided.
Sets the ping interval for a pool, which is the time interval between pings of servers to verify that they are still alive. These pings are used by the server to monitor the health of the client. Make sure that the ping interval is less than the maximum time between pings allowed by the bridge server.
(number)
is the number of milliseconds for the interval.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when too many arguments are given, or when no argument is provided.
Restrict server to server hops for partitioned region operations of put, get, and destroy when set to true
, such that the operations go directly to the server containing the primary copy of the data entry.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
enabled
is not a boolean, when too many arguments are given, or when no argument is provided.
Sets the duration to wait for a response from a server before timing out the operation and trying another server (if any are available).
(number)
is the number of milliseconds for the timeout.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when
milliseconds
is less than or equal to zero, when too many arguments are given,
or when no argument is provided.
Sets the number of retry attempts for a pool after a timeout or exception. A value of -1 indicates that a request should be tried against every available server before failing.
(number)
is the number of retry attempts.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
retries
is not a number, when too many arguments are given, or when no argument is provided.
Sets a server group for a pool. If the server group is the empty string, then the pool connects to all servers.
(string)
is the string name of the server group.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
serverGroupName
is not a string, when too many arguments are given, or when no argument is provided.
Sets the size of the socket buffer for a pool.
(number)
is a number representing the size of the buffer in bytes.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
size
is not a number, when
size
is less than or equal to zero, when too many arguments are given, or when no argument is provided.
Sets the time interval between sends of client statistics to the server. A value of zero disables the sending of client statistics to the server.
(number)
is the number of milliseconds for the interval.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when too many arguments are given, or when no argument is provided.
Sets the subscription acknowledgement interval for a pool.
(number)
interval in milliseconds the client will wait before sending acknowledgements to
the cache server for events received from the server subscriptions.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when
milliseconds
is less than or equal to zero, when too many arguments are given, or when no argument is provided.
Configure if a pool can have server to client subscriptions.
(boolean)
is a boolean that, when
true
, allows subscriptions, and when
false
, ignores all other subscription attributes.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
enabled
is not a boolean, when too many arguments are given, or when no argument is provided.
Sets the subscription message tracking timeout for a pool. This timeout is the time to live for subscription events recieved from the server. Increase the timeout to minimize duplicate events.
(number)
is the number of milliseconds for the timeout.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when
milliseconds
is less than or equal to zero, when too many arguments are given, or when no argument is provided.
Sets the redundancy level for a pool. If zero, there are no redundant copies kept on the server.
(number)
is the number of copies to keep on the server.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
level
is not a number, when
level
is less than zero when too many arguments are given, or when no argument is provided.
Configure the thread local connections policy for a pool.
(boolean)
is a boolean that, when
true
, has a thread check the thread local cache any time it goes to use a connection, and when
false
, returns threads to the pool as soon as the operation completes.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
enabled
is not a boolean, when too many arguments are given, or when no argument is provided.
Sets the time interval between updates of the locator list for a pool.
(number)
is the number of milliseconds for the interval.
PoolFactory
:
Returns the updated
PoolFactory
object. Returns an error when
milliseconds
is not a number, when too many arguments are given, or when no argument is provided.
Manages creation and access to pools for a client. PoolManager is used to create a PoolFactory.
Instantiates a factory with which to create pools.
PoolFactory
:
a PoolFactory object
cache = await cacheFactory.create()
poolFactory = await cache.getPoolManager().createFactory()
console.log('Configuring the pool factory to find a locator at localhost:10337')
poolFactory.addLocator('localhost', 10337)
poolFactory.create('pool')
A region is a collection of key-value pair entries.
Returns the current attributes object.
Promise<object>
:
a Promise that resolves to an object containing all the attributes of the
region. These objects and their types are defined:
cachingEnabled
(boolean)
clientNotificationEnabled
(boolean)
concurrencyChecksEnabled
(boolean)
concurrencyLevel
(number)
diskPolicy
(number)
entryIdleTimeout
(number)
entryTimeToLive
(number)
initialCapacity
(number)
loadFactor
(number)
lruEntriesLimit
(number)
lruEvictionAction
(number)
poolName
(string)
regionIdleTimeout
(number)
regionTimeToLive
(number)
Detailed documentation of region attributes may be found at Region Attributes.
const attributes = await region.attributes()
console.log('cachingEnabled=' + attributes.cachingEnabled)
Removes all entries from a replicated region. clear() is not supported for partitioned regions.
any
:
a Promise that resolves to empty on success or returns an error on failure. Returns an
UnsupportedOperationException if the region is a partitioned type region.
await region.put('key', 'value')
await region.clear()
value = await region.get('key')
if (typeof value === 'undefined') {
console.log('Value no longer exists in region, as expected')
}
Removes the region from existence.
Caution: This also removes the corresponding region from the cluster's servers.
To remove only the client region, call region.localDestroyRegion()
.
any
:
a Promise that resolves to empty on success. Returns an error if the region is not on the server.
let region = cache.getRegion('exampleRegion')
await region.destroyRegion()
region = cache.getRegion('exampleRegion')
if (typeof region === 'undefined') {
console.log('Successfully destroyed region')
}
Returns an array containing all the region's entries.
Promise<Array<any>>
:
a Promise that resolves to an array of entries on success.
region = await cache.getRegion('exampleRegion')
await region.clear()
await region.putAll({ foo: 10, bar: 'quux', baz: 12 })
const results = await region.entries()
console.log('Region entry count: ' + results.length)
console.log('foo = ' + results['foo'])
console.log('bar = ' + results['bar'])
console.log('baz = ' + results['baz'])
Invokes a function that is already deployed on the server.
(string)
is the name of the function on the server to be executed.
(object?)
is an object that contains:
args
: an object that contains the arguments for functionNamefilter
: an array that contains what server keys to filterPromise<Array<any>>
:
a Promise that resolves to an array containing the results from the function's execution. Returns an error if one of the following happens:
options
is not an objectfunctionName
is undefined
args
is given a functionfunctionName
is not found on the serverfunctionName
throws an error on the serverfunctionName
sends an exception with its resultsawait region.put('one', 1)
await region.put('two', 2)
let data = await region.executeFunction('io.pivotal.node_gemfire.SumRegion')
expect(data).toEqual([3])
Executes a query to determine if that query returns a value.
Promise<boolean>
:
a Promise that resolves to
true
if the query returns a value, and resolves to
false
if the query does not return a value. Returns an error if the query string is invalid or empty.
await region.put('key1', { foo: 1 })
let does_it_exist = await region.existsValue('foo = 1')
expect(does_it_exist).toEqual(true)
does_it_exist = await region.existsValue('bar = 2')
expect(does_it_exist).toEqual(false)
Does a lookup to retrieve the value associated with key
.
(any)
is the key associated with a region entry.
Promise<any>
:
a Promise that resolves to the value found or
null
if the key is not found. Returns an error if one of the following happens:
key
is passed.key
is invalid. Invalid keys are null
, undefined
, or {}
(the empty object).key
parameter is a function.await region.put('high', 'five')
const data = await region.get('high')
expect(data).toEqual('five')
Retrieves all entries for all keys passed in.
(Array<any>)
is an array of keys.
Promise<object>
:
a Promise that resolves to an object containing entries. Each entry is a key/value pair. Returns an error if one of the following happens:
keyArray
is empty.keyArray
is null
.keyArray
is undefined
.keyArray
is not an array.keyArray
is a function.let result = await region.getAll(['a', 'dd'])
Object.keys(result).length).toBe(2)
console.log('Item "a" is ' + result.a);
console.log('Item "dd" is ' + result.dd);
Retrieves all keys from the client cache for a CACHING_PROXY
type
of region.
Retrieves all keys from the server for a PROXY
type of region.
Promise<Array<any>>
:
a Promise that resolves to an array of keys.
await region.putAll({ foo: 1, bar: 2, baz: 3 })
let results = await region.keys()
expect(results.length).toEqual(3)
expect(results).toContain('foo')
expect(results).toContain('bar')
expect(results).toContain('baz')
Removes the client region from existence.
Note: Only the local region is destroyed. A corresponding region on the servers is not destroyed. To destroy the corresponding region on the servers, use region.destroyRegion()
.
any
:
a Promise that resolves to a empty on success.
const region = cache.createRegion('exampleRegion', { type: 'CACHING_PROXY' })
await region.localDestroyRegion()
expect(cache.getRegion('exampleRegion')).not.toBeDefined()
For an event type defined by eventType
, invokes the given function on that
event.
(string)
distinguishes
'afterCreate'
,
'afterUpdate'
, or
'afterDestroy'
.
'afterCreate'
is an event fired after a new region entry is created'afterUpdate'
is an event fired after an existing region entry is modified'afterDestroy'
is an event fired after an existing region entry is removed(function)
is the function to be invoked after the event occurs.
The eventHandler function takes a single parameter, an object, and returns nothing. The
object passed to the handler has 3 fields: key, oldValue, and newValue. The
types of these fields vary, and are determined by the type of the key/value
in the region.
region.on('afterCreate', (event) => {
console.log('afterCreate called, event.key=' + event.key + ', oldValue=' + event.oldValue +
', newValue=' + event.newValue)
}))
})
// Should see output from afterCreate callback when this put completes
await region.put('foo', 'bar')
Inserts a new region entry consisting of a key/value pair into the region.
If the key already exists in the region, the existing entry is updated
with the specified value.
The value may not be a function or null
.
(any)
is the key of the entry.
(any)
is the value for the key.
Promise
:
a Promise that resolves to empty on success. Returns an error if one of the following happens:
key
is passed.value
is passed.value
is null
.value
is a function.await region.put('high', 'five')
const data = await region.get('high')
// data should be 'five'
console.log('get: data is ' = data)
Insert all key/value pairs in the region.
(any)
is an object containing the key value pairs.
Promise
:
a Promise that resolves to empty on success. Returns an error if one of the following happens:
keyObject
is passed.null
.keyObject
is null
.keyObject
is undefined
.keyObject
is not an object.region.putAll({ key1: 'foo', key2: 'bar', 1: 'one' })
// is equivalent to these three put() calls:
region.put( 'key1', 'foo' )
region.put( 'key2', 'bar' )
region.put( 1, 'one' )
Retrieves all values from the region that match the query.
(any)
Promise<Array<any>>
:
a Promise that resolves to an array of values. Returns an error when no
queryString
is passed or an invalid
queryString
is passed.
await region.put('key1', 1)
await region.put('key2', 2)
await region.put('key3', 3)
let array = await region.query('this > 1')
console.log('got ' + array.length + ' results')
for (i = 0; i < array.length; i++) {
console.log(' ' + i + '. ' + array[i])
}
Causes an invocation of a callback on each region operation.
The callback is specified by a call to Region.on()
.
Promise
:
a Promise that resolves to empty on success.
await region.registerAllKeys()
region.on('afterCreate', do_stuff)
// Should trigger a call to do_stuff()
await region.put('foo', 'bar')
Removes the region entry for the given key.
(any)
is the key of the entry to be removed.
Promise
:
a Promise that resolves to empty on success. Returns
null
if the key is not present in the region. Returns an error if one of the following happens:
key
is specified.key
is null
.key
is undefined
.key
is an empty array.key
is a function.await region.put('foo', 'bar')
await region.remove('foo')
let value = await region.get('foo')
expect(value).toBeNull()
Runs a query, expecting to match exactly one region entry,
returning the value of that entry.
If you want to query for multiple results, use Region.query()
.
Promise<any>
:
a Promise that resolves to the entry's value that matches the query. Returns an error when no
queryString
is passed, the
queryString
returns more than one result, or the
queryString
is invalid.
await region.putAll({ key1: { foo: 1 }, key2: { foo: 2 }, key3: { foo: 3 } })
let value = await region.selectValue('foo = 2')
console.log('Value is ' + value)
Retrieves all the keys in the region from the server.
Note: Exercise caution using this function. Composing the resulting array of keys for a large region can exhaust available server memory space.
Promise<Array<any>>
:
a Promise that resolves to an array of keys.
await region.putAll({ foo: 7, bar: 'qux', baz: 9 })
const result = await region.serverKeys()
expect(result.length).toEqual(3)
expect(result).toContain('foo')
expect(result).toContain('bar')
expect(result).toContain('baz')
Tells the server not to trigger entry events for this app instance.
Promise
:
a Promise that resolves to empty on success.
region.on('afterCreate', () => { console.log('callback invoked') })
await region.unregisterAllKeys()
region.put('key1', 'hello') // callback will not be invoked
Retrieves all the values on the region.
Note: Exercise caution using this function. Composing the resulting array of values for a large region can exhaust available server memory space.
Promise<Array<any>>
:
a Promise that resolves to an array of values.
await region.putAll({ foo: 7, bar: 'qux', baz: 9 })
const result = await region.values()
console.log('Received ' + result.length + ' values.')
for (i = 0; i < result.length; i++) {
console.log(' value: ', result[i])
}