Adds a MapListener for this map.
registration id of the listener
listener object
Optional key: Koptional key to restrict events to associated entry
Optional includeValue: booleanif set to true, event message will contain
new value of the key
Adds a MapListener for this map. Listener will get notified for map add/remove/update/evict events filtered by the given predicate.
registration id of the listener
listener object
predicate
Optional key: Koptional key to restrict events to associated entry
Optional includeValue: booleanif set to true, event message will contain
new value of the key
Adds an index to this map for the specified entries so that queries can run faster.
Let's say your map values are Employee objects.
class Employee implements Portable {
active: boolean = false;
age: number;
name: string = null;
// other fields
// portable implementation
}
If you are querying your values mostly based on age and active then you may consider indexing these fields.
const map = client.getMap('employees');
// Sorted index for range queries:
map.addIndex({
type: 'SORTED',
attributes: ['age']
});
// Hash index for equality predicates:
map.addIndex({
type: 'HASH',
attributes: ['active']
});
Index attribute should either have a getter method or be public. You should also make sure to add the indexes before adding entries to this map.
Time to Index
Indexing time is executed in parallel on each partition by operation threads. The Map is not blocked during this operation.
The time taken in proportional to the size of the Map and the number Members.
Searches while indexes are being built
Until the index finishes being created, any searches for the attribute will use a full Map scan, thus avoiding using a partially built index and returning incorrect results.
AssertionError if indexConfig is null
TypeError If the specified index configuration is invalid.
Index configuration.
Applies the aggregation logic on all map entries and returns the result.
Fast-Aggregations are the successor of the Map-Reduce Aggregators. They are equivalent to the Map-Reduce Aggregators in most of the use-cases, but instead of running on the Map-Reduce engine they run on the Query infrastructure. Their performance is tens to hundreds times better due to the fact that they run in parallel for each partition and are highly optimized for speed and low memory consumption.
AssertionError if aggregator is null
the result of the given type
type of the result
aggregator to aggregate the entries with
Applies the aggregation logic on map entries filtered with the Predicated and returns the result.
Fast-Aggregations are the successor of the Map-Reduce Aggregators. They are equivalent to the Map-Reduce Aggregators in most of the use-cases, but instead of running on the Map-Reduce engine they run on the Query infrastructure. Their performance is tens to hundreds times better due to the fact that they run in parallel for each partition and are highly optimized for speed and low memory consumption.
AssertionError if aggregator or predicate is null
the result of the given type
type of the result
aggregator to aggregate the entries with
predicate to filter the entries with
Removes specified key from the map. Unlike remove this method does not return the deleted value. Therefore, it eliminates deserialization cost of the returned value.
AssertionError if key is null
the key of the map entry
Queries the map based on the specified predicate and returns matching entries. Specified predicate runs on all members in parallel.
AssertionError if predicate is null
result entry set of the query.
specified query criteria.
Applies the user defined EntryProcessor to the all entries in the map.
Returns the results mapped by each key in the map.
Note that entryProcessor should be registered at server side too.
AssertionError if entryProcessor is null
entries after EntryProcessor is applied
EntryProcessor object
Optional predicate: Predicateif specified, entry processor is applied to the entries that satisfy this predicate
Applies the user defined EntryProcessor to the entry mapped by the key.
AssertionError if key or entryProcessor is null
result of entry process
entry processor is applied only to the value that is mapped with this key
entry processor to be applied
Applies the user defined EntryProcessor to the entries mapped by the given keys.
AssertionError if keys is not an array
result of entry process
keys to be processed
Releases the lock for the specified key regardless of the owner. This operation always unlocks the key.
Warning: This method should be used with caution. It releases the lock even if it was acquired by another client. That can lead to data inconsistencies if not used properly.
AssertionError if key is null
the key of the map entry
Returns a key-value pair representing the association of given key.
AssertionError if key is null
the key of the map entry
Locks the given key for this map. Promise is resolved when lock is successfully acquired. This means it may never be resolved if some other process holds the lock and does not unlock it. A lock may be acquired on non-existent keys. In that case, other clients would block until the non-existent key is unlocked. If the lock holder introduces the key to the map, the put operation is not blocked. If a client not holding a lock on the non-existent key tries to introduce the key while a lock exists on the non-existent key, the put operation blocks until it is unlocked.
Locking is reentrant, meaning that the lock owner client can obtain the
lock multiple times. If the lock was acquired multiple times, then unlock()
method must be called the same amount of times, otherwise the lock will
remain unavailable.
Important:
In the Node.js client, all lock operations from the same client instance share the same lock ownership.
This differs from the Java client where each thread has separate lock ownership.
Use LockContext.run method to limit the lock ownership in concurrent code.
AssertionError if key is null
the key of the map entry
Optional leaseTime: numberlock is automatically unlocked after leaseTime
milliseconds; defaults to infinity
Associates the specified value with the specified key. If key was associated with another value, it replaces the old value.
The entry will expire and get evicted after the TTL. It limits the
lifetime of the entries relative to the time of the last write access
performed on them. If the TTL is 0, then the entry lives forever.
If the TTL is negative, then the TTL from the map configuration will
be used (default: forever).
The entry will expire and get evicted after the Max Idle time. It limits
the lifetime of the entries relative to the time of the last read or write
access performed on them. If the Max Idle is 0, then the entry lives
forever. If the Max Idle is negative, then the Max Idle from the map
configuration will be used (default: forever). The time precision is
limited by 1 second. The Max Idle that is less than 1 second can
lead to unexpected behaviour.
AssertionError if key or value is null
old value if there was any, null otherwise
the key of the map entry
new value
Optional ttl: number | Longoptional time to live in milliseconds. 0 means infinite,
negative means map config default. Time resolution for TTL
is seconds. The given value is rounded to the next closest
second value.
Optional maxIdle: number | Longoptional maximum time in milliseconds for this entry to
stay idle in the map. 0 means infinite, negative means
map config default.
Puts all key value pairs from this array to the map as key -> value mappings.
The behaviour of this operation is undefined if the specified pairs are modified while this operation is in progress.
Interactions with the map store
For each element not found in memory
MapLoader#load(Object) is invoked to load the value from
the map store backing the map, which may come at a significant
performance cost. Exceptions thrown by load fail the operation
and are propagated to the caller. The elements which were added
before the exception was thrown will remain in the map, the rest
will not be added.
If write-through persistence mode is configured,
MapStore#store(Object, Object) is invoked for each element
before the element is added in memory, which may come at a
significant performance cost. Exceptions thrown by store fail the
operation and are propagated to the caller. The elements which
were added before the exception was thrown will remain in the map,
the rest will not be added.
If write-behind persistence mode is configured with write-coalescing
turned off, this call may be rejected with ReachedMaxSizeError
if the write-behind queue has reached its per-node maximum capacity.
AssertionError if any key or value in the specified array is null
entries to be put
Puts specified key value association if it was not present before.
The entry will expire and get evicted after the TTL. It limits the
lifetime of the entries relative to the time of the last write access
performed on them. If the TTL is 0, then the entry lives forever.
If the TTL is negative, then the TTL from the map configuration will
be used (default: forever).
The entry will expire and get evicted after the Max Idle time. It limits
the lifetime of the entries relative to the time of the last read or write
access performed on them. If the Max Idle is 0, then the entry lives
forever. If the Max Idle is negative, then the Max Idle from the map
configuration will be used (default: forever). The time precision is
limited by 1 second. The Max Idle that is less than 1 second can
lead to unexpected behaviour.
AssertionError if key or value is null
old value of the entry
the key of the map entry
new value
Optional ttl: number | Longoptional time to live in milliseconds. 0 means infinite,
negative means map config default. Time resolution for TTL
is seconds. The given value is rounded to the next closest
second value.
Optional maxIdle: number | Longoptional maximum time in milliseconds for this entry to
stay idle in the map. 0 means infinite, negative means
map config default.
Same as put except it does not call underlying MapStore.
AssertionError if key or value is null
the key of the map entry
new value
Optional ttl: number | Longoptional time to live in milliseconds. 0 means infinite,
negative means map config default. Time resolution for TTL
is seconds. The given value is rounded to the next closest
second value.
Optional maxIdle: number | Longoptional maximum time in milliseconds for this entry to
stay idle in the map. 0 means infinite, negative means
map config default.
Removes specified key from map. If optional value is specified, the key is removed only if currently mapped to given value. Note that serialized version of the value is used in comparison.
AssertionError if key is null
value associated with key, null if the key did not exist
before. If optional value is specified, a boolean representing
whether or not entry is removed is returned
the key of the map entry
Optional value: Vexpected value
Removes all entries which match with the supplied predicate. Note that calling this method also removes all entries from caller's Near Cache. If this map has index, matching entries will be found via index search, otherwise they will be found by full-scan.
AssertionError if predicate is null
matching entries with this predicate will be removed from the map
Replaces value of the key if only it was associated to oldValue.
AssertionError if key, oldValue or newValue is null
true if the value was replaced
the key of the map entry
expected old value
new value
Similar to put except it does not return the old value.
The entry will expire and get evicted after the TTL. It limits the
lifetime of the entries relative to the time of the last write access
performed on them. If the TTL is 0, then the entry lives forever.
If the TTL is negative, then the TTL from the map configuration will
be used (default: forever).
The entry will expire and get evicted after the Max Idle time. It limits
the lifetime of the entries relative to the time of the last read or write
access performed on them. If the Max Idle is 0, then the entry lives
forever. If the Max Idle is negative, then the Max Idle from the map
configuration will be used (default: forever). The time precision is
limited by 1 second. The Max Idle that is less than 1 second can
lead to unexpected behaviour.
AssertionError if key or value is null
the key of the map entry
new value
Optional ttl: number | Longoptional time to live in milliseconds. 0 means infinite,
negative means map config default. Time resolution for TTL
is seconds. The given value is rounded to the next closest
second value.
Optional maxIdle: number | Longoptional maximum time in milliseconds for this entry to
stay idle in the map. 0 means infinite, negative means
map config default.
Puts all key value pairs from this array to the map as key -> value
mappings without loading non-existing elements from map store which
is more efficient than putAll.
This method breaks the contract of EntryListener. EntryEvent of all
the updated entries will have null oldValue even if they exist previously.
The behaviour of this operation is undefined if the specified pairs are modified while this operation is in progress.
Interactions with the map store
If write-through persistence mode is configured,
MapStore#store(Object, Object) is invoked for each element
before the element is added in memory, which may come at a
significant performance cost. Exceptions thrown by store fail the
operation and are propagated to the caller. The elements which
were added before the exception was thrown will remain in the map,
the rest will not be added.
If write-behind persistence mode is configured with write-coalescing
turned off, this call may be rejected with ReachedMaxSizeError
if the write-behind queue has reached its per-node maximum capacity.
Works with Hazelcast versions 4.1 and above.
AssertionError if any key or value in the specified array is null
entries to be put
Updates the TTL (time to live) value of the entry specified by key
with a new TTL value. New TTL value is valid starting from the time
this operation is invoked, not since the time the entry was created.
If the entry does not exist or is already expired, this call has no
effect.
The entry will expire and get evicted after the TTL. If the TTL is 0,
then the entry lives forever. If the TTL is negative, then the TTL
from the map configuration will be used (default: forever).
If there is no entry with key key or is already expired, this call
makes no changes to entries stored in this map.
true if the entry exists and its TTL value is changed,
false otherwise
AssertionError if key or ttl is null
the key of the map entry
time to live in milliseconds. 0 means infinite, negative
means map config default. Time resolution for TTL is seconds.
The given value is rounded to the next closest second value.
Tries to acquire the lock for the specified key.
If lock is not available, server immediately responds with false.
Locking is reentrant, meaning that the lock owner client can obtain
the lock multiple times. If the lock was acquired multiple times, then
unlock() method must be called the same amount of times, otherwise the
lock will remain unavailable.
Important:
In the Node.js client, all lock operations from the same client instance share the same lock ownership.
Use LockContext.run method to limit the lock ownership in concurrent code.
AssertionError if key is null
the key of the map entry
Optional timeout: numberserver waits for timeout milliseconds to acquire
the lock before giving up; defaults to 0
Optional leaseTime: numberlock is automatically release after leaseTime
milliseconds; defaults to infinity
Tries to put specified key value pair into the map. If this method returns
false, it indicates that caller thread was not able to acquire the lock for
given key in timeout milliseconds.
AssertionError if key, value or timeout is null
the key of the map entry
new value
maximum time to wait in milliseconds
Tries to remove specified key from the map. If this method returns
false, it indicates that caller thread was not able to acquire the lock
for given key in timeout milliseconds.
AssertionError if key or timeout is null
the key of the map entry
maximum time to wait in milliseconds
Returns a list of values contained in this map.
Queries the map based on the specified predicate and returns the values of matching entries. Specified predicate runs on all members in parallel.
AssertionError if predicate is null
a list of values that satisfies the given predicate
Generated using TypeDoc
Concurrent, distributed, observable and queryable map.
Methods that require serialization/deserialization may throw RangeError, e.g when there is no suitable serializer for a certain type.