new Client(args, optionsopt) → {Promise.<ReturnType.<Client>>}
Infinispan client constructor taking an optional initial address,
or multiple addresses, to which the client will try to connect to,
as well as optional configuration settings.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
ServerAddress | Array.<ServerAddress> | Optional single or multiple addresses to which to connect. If none provided, the client will connect to localhost:11222 address by default. | |
options |
ClientOptions |
<optional> |
Optional configuration settings. |
- Since:
- 0.3
- Source:
Returns:
- Type
- Promise.<ReturnType.<Client>>
Examples
client({port: 11222, host: 'localhost'})
client([{port: 11322, host: 'node1'}, {port: 11422, host: 'node2'}])
client({port: 11522, host: 'myhost'}, {version: '2.2'})
client([{port: 11522, host: 'myhost'}, {port: 11622, host: 'myhost'}],
{version: '2.2', cacheName: 'myCache'})
Methods
addListener(event, listener, optsopt) → {Promise.<String>}
Add an event listener.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
String | Event to add listener to. Possible values are: 'create', 'modify', 'remove' and 'expiry'. | |
listener |
function | Function to invoke when the listener event is received. 'create' and 'modify' events callback the function with key, entry version and listener id. 'remove' and 'expiry' events callback the function with key and listener id. | |
opts |
ListenOptions |
<optional> |
Options for adding listener. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with the identifier of the listener.
This identifier can be used to register multiple callbacks with the
same listener, or to remove the listener.
- Type
- Promise.<String>
addScript(scriptName, script) → {Promise}
Add script to server(s).
Parameters:
Name | Type | Description |
---|---|---|
scriptName |
String | Name of the script to store. |
script |
String | Script to store in server. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed when the script has been stored.
- Type
- Promise
clear() → {Promise}
Clear all entries stored in server(s).
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed when the clear has been completed.
- Type
- Promise
containsKey(k) → {Promise.<boolean>}
Check whether the given key is present.
Parameters:
Name | Type | Description |
---|---|---|
k |
String | Object | Key to check for presence. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with true if there is a value
associated with the key, or false otherwise.
- Type
- Promise.<boolean>
disconnect() → {Promise.<void>}
Disconnect client from backend server(s).
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed once client has
completed disconnection from server(s).
- Type
- Promise.<void>
execute(scriptName, paramsopt) → {Promise.<(String|Array.<String>)>}
Execute the named script passing in optional parameters.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scriptName |
String | Name of the script to execute. | |
params |
Array.<ExecParams> |
<optional> |
Optional array of named parameters to pass to script in server. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with either the value returned by the
script after execution for local scripts, or an array of values
returned by the script when executed in multiple servers for
distributed scripts.
- Type
- Promise.<(String|Array.<String>)>
get(k) → {Promise.<?String>}
Get the value associated with the given key parameter.
Parameters:
Name | Type | Description |
---|---|---|
k |
String | Object | Key to retrieve. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with the value associated with
the key, or undefined if the value is not present.
- Type
- Promise.<?String>
getAll(keys) → {Promise.<Array.<Entry>>}
Retrieves all of the entries for the provided keys.
Parameters:
Name | Type | Description |
---|---|---|
keys |
Array.<String> | Array.<Object> | Keys to find values for. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with an array of entries for all
keys found. If a key does not exist, there won't be an entry for that
key in the returned array.
- Type
- Promise.<Array.<Entry>>
getTopologyInfo() → {TopologyInfo}
Get server topology related information.
- Since:
- 0.3
- Source:
Returns:
An object instance that can be used to query diverse information
related to the server topology information.
- Type
- TopologyInfo
getWithMetadata(k) → {Promise.<?MetadataValue>}
Get the value and metadata associated with the given key parameter.
Parameters:
Name | Type | Description |
---|---|---|
k |
String | Object | Key to retrieve. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with the value and metadata
associated with the key, or undefined if the value is not present.
- Type
- Promise.<?MetadataValue>
iterator(batchSize, optsopt) → {Promise.<Iterator>}
Iterate over the entries stored in server(s).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
batchSize |
Number | The number of entries transferred from the server at a time. | |
opts |
IteratorOptions |
<optional> |
Optional iteration settings. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with an iterator that can be used
to retrieve stored elements.
- Type
- Promise.<Iterator>
ping() → {Promise}
Pings the server(s).
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed when ping response was received.
- Type
- Promise
put(k, v, optsopt) → {Promise.<?(String|Object)>}
Associates the specified value with the given key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
k |
String | Object | Key with which the specified value is to be associated. | |
v |
String | Object | Value to be associated with the specified key. | |
opts |
StoreOptions |
<optional> |
Optional store options. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with undefined unless 'previous'
option has been enabled and a previous value exists, in which case it
would return the previous value.
- Type
- Promise.<?(String|Object)>
putAll(pairs, optsopt) → {Promise}
Stores all of the mappings from the specified entry array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pairs |
Array.<Entry> | key/value pair mappings to be stored | |
opts |
MultiStoreOptions |
<optional> |
Optional storage options to apply to all entries. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed when all entries have been stored.
- Type
- Promise
putIfAbsent(k, v, optsopt) → {Promise.<(Boolean|String|Object)>}
Conditional store operation that associates the key with the given
value if the specified key is not already associated with a value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
k |
String | Object | Key with which the specified value is to be associated. | |
v |
String | Object | Value to be associated with the specified key. | |
opts |
StoreOptions |
<optional> |
Optional store options. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with true if the mapping was stored,
or false if the key is already present.
If the 'previous' option is enabled, it returns the existing value
or undefined if the key does not exist.
- Type
- Promise.<(Boolean|String|Object)>
query(q) → {Promise.<?Array.<Object>>}
Query the server with the given queryString.
Parameters:
Name | Type | Description |
---|---|---|
q |
Object | query to retrieve. |
- Since:
- 1.3
- Source:
Returns:
A promise that will be completed with the array of values associated with
the query, or empty array if the no values matches the query.
- Type
- Promise.<?Array.<Object>>
remove(k, optsopt) → {Promise.<(Boolean|String|Object)>}
Removes the mapping for a key if it is present.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
k |
String | Object | Key whose mapping is to be removed. | |
opts |
RemoveOptions |
<optional> |
Optional remove options. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with true if the mapping was removed,
or false if the key did not exist.
If the 'previous' option is enabled, it returns the value
before removal or undefined if the key did not exist.
- Type
- Promise.<(Boolean|String|Object)>
removeListener(listenerId) → {Promise}
Remove an event listener.
Parameters:
Name | Type | Description |
---|---|---|
listenerId |
String | Listener identifier to identify listener to remove. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed when the listener has been removed.
- Type
- Promise
removeWithVersion(k, version, optsopt) → {Promise.<(Boolean|String|Object)>}
Removes the given entry only if its version matches the
supplied version.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
k |
String | Object | Key whose mapping is to be removed. | |
version |
Buffer | binary buffer version that should match the one in the server for the operation to succeed. Version information can be retrieved with getWithMetadata method. | |
opts |
RemoveOptions |
<optional> |
Optional remove options. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with true if the version matches
and the mapping was removed, otherwise it returns false if not
removed because key does not exist or version sent does not match
server-side version.
If the 'previous' option is enabled, it returns the value that was
removed if the version matches. If the version does not match, the
current value is returned. Fianlly if the key did not exist it
returns undefined.
- Type
- Promise.<(Boolean|String|Object)>
replace(k, v, optsopt) → {Promise.<(Boolean|String|Object)>}
Conditional store operation that replaces the entry for a key only
if currently mapped to a given value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
k |
String | Object | Key with which the specified value is associated. | |
v |
String | Object | Value expected to be associated with the specified key. | |
opts |
StoreOptions |
<optional> |
Optional store options. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with true if the mapping was replaced,
or false if the key does not exist.
If the 'previous' option is enabled, it returns the value that was
replaced or undefined if the key did not exist.
- Type
- Promise.<(Boolean|String|Object)>
replaceWithVersion(k, v, version, optsopt) → {Promise.<(Boolean|String|Object)>}
Replaces the given value only if its version matches the supplied
version.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
k |
String | Object | Key with which the specified value is associated. | |
v |
String | Object | Value expected to be associated with the specified key. | |
version |
Buffer | binary buffer version that should match the one in the server for the operation to succeed. Version information can be retrieved with getWithMetadata method. | |
opts |
StoreOptions |
<optional> |
Optional store options. |
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with true if the version matches
and the mapping was replaced, otherwise it returns false if not
replaced because key does not exist or version sent does not match
server-side version.
If the 'previous' option is enabled, it returns the value that was
replaced if the version matches. If the version does not match, the
current value is returned. Fianlly if the key did not exist it
returns undefined.
- Type
- Promise.<(Boolean|String|Object)>
size() → {Promise.<Number>}
Count of entries in the server(s).
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with the number of entries stored.
- Type
- Promise.<Number>
stats() → {Promise.<Array.<StatsItem>>}
Retrieve various statistics from server(s).
- Since:
- 0.3
- Source:
Returns:
A promise that will be completed with an array of statistics, where
each element will have a single property. This single property will
have the statistic name as property name and statistic value as
property value.
- Type
- Promise.<Array.<StatsItem>>
toString()
Get client information represented as a string.
- Since:
- 0.4
- Source: