Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface NamedMap<K, V>

A Map-based data-structure that manages entries across one or more processes. Entries are typically managed in memory, and are often comprised of data that is also stored persistently, on disk.

Type parameters

  • K

    the type of the map entry keys

  • V

    the type of the map entry values

Hierarchy

Index

Properties

Readonly active

active: boolean

true if this cache is active.

Readonly destroyed

destroyed: boolean

Signifies whether or not this NamedMap has been destroyed.

Readonly empty

empty: Promise<boolean>

true if this map contains no key-value mappings.

Readonly name

name: string

The name of this NamedMap.

Readonly released

released: boolean

true if this cache has been released

Readonly size

size: Promise<number>

Signifies the number of key-value mappings in this map.

returns

the number of key-value mappings in this map

Methods

addIndex

  • Add an index to this map.

    remarks

    Adds an index to this map. Example:

    cache.addIndex(Extractors.extract('name'))

    Parameters

    • extractor: ValueExtractor

      The ValueExtractor object that is used to extract an indexable Object from a value stored in the indexed Map. Must not be null.

    • Optional ordered: boolean

      true iff the contents of the indexed information should be ordered false otherwise.

    • Optional comparator: Comparator

      The Comparator object which imposes an ordering on entries in the indexed map or null if the entries' values natural ordering should be used.

    Returns Promise<void>

    A Promise that resolves when the operation completes.

addMapListener

  • addMapListener(listener: MapListener<K, V>, keyOrFilter?: K | Filter, isLite?: boolean): Promise<void>
  • Add a MapListener that will receive events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included.

    Parameters

    • listener: MapListener<K, V>

      the MapListener to receive events

    • Optional keyOrFilter: K | Filter

      the optional the key that identifies the entry for which to raise events or a filter that will be passed MapEvent objects to select from; a MapEvent will be delivered to the listener only if the filter evaluates to true for that MapEvent (see MapEventFilter); null is equivalent to a filter that always returns true

    • Optional isLite: boolean

      optionally pass true to indicate that the MapEvent objects do not have to include the old or new values in order to allow optimizations

    Returns Promise<void>

aggregate

  • Perform an aggregating operation against the entries specified by the passed keys.

    Type parameters

    Parameters

    • keys: Iterable<K>

      the Iterable of keys that specify the entries within this Map to aggregate across

    • aggregator: EntryAggregator<K, V, R>

      the EntryAggregator that is used to aggregate across the specified entries of this Map

    Returns Promise<R>

  • Perform an aggregating operation against the set of entries that are selected by the given Filter.

    Type parameters

    Parameters

    • filter: Filter

      the Filter that is used to select entries within this Map to aggregate across

    • aggregator: EntryAggregator<K, V, R>

      the EntryAggregator that is used to aggregate across the specified entries of this Map

    Returns Promise<R>

  • Perform an aggregating operation against all the entries.

    Type parameters

    Parameters

    Returns Promise<R>

clear

  • clear(): Promise<void>
  • Clears all the mappings in the 'NamedMap'.

    Returns Promise<void>

    a Promise which resolves once the operation is complete

delete

  • delete(key: K): Promise<V | null>
  • Removes the mapping for a key from this map if it is present.

    Parameters

    • key: K

      key whose mapping is to be removed from the map

    Returns Promise<V | null>

    a Promiseresolving to the previous value associated with key, or null if there was no mapping for key

destroy

  • destroy(): Promise<void>
  • Release and destroy this cache.

    Warning: This method is used to completely destroy the specified cache across the cluster. All references in the entire cluster to this cache will be invalidated, the cached data will be cleared, and all resources will be released.

    Returns Promise<void>

entries

  • Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map.

    Returns Promise<RemoteSet<MapEntry<K, V>>>

    a set view of the mappings contained in this map

  • Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is a MapEntry.

    Unlike the entrySet() method, the set returned by this method may not be backed by the map, so changes to the set may not be reflected in the map, and vice-versa.

    Parameters

    • filter: Filter

      the Filter object representing the criteria that the entries of this map should satisfy

    • Optional comparator: Comparator

      the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be used

    Returns Promise<RemoteSet<MapEntry<K, V>>>

    a set of entries that satisfy the specified criteria

forEach

  • forEach(action: (value: V, key: K, map: NamedMap<K, V>) => void, thisArg?: any): Promise<void>
  • forEach(action: (value: V, key: K, map: NamedMap<K, V>) => void, keys: Iterable<K>, thisArg?: any): Promise<void>
  • forEach(action: (value: V, key: K, map: NamedMap<K, V>) => void, filter: Filter, thisArg?: any): Promise<void>
  • Perform the given action for each entry selected by the specified key set until all entries have been processed or the action raises an error.

    Errors raised by the action are relayed to the caller.

    The implementation processes each entry on the client and should only be used for read-only client-side operations (such as adding map entries to a UI widget, for example).

    Any entry mutation caused by the specified action will not be propagated to the server when this method is called on a distributed map, so it should be avoided. The mutating operations on a subset of entries should be implemented using invokeAll.

    Parameters

    • action: (value: V, key: K, map: NamedMap<K, V>) => void

      the action to be performed for each entry

        • (value: V, key: K, map: NamedMap<K, V>): void
        • Parameters

          Returns void

    • Optional thisArg: any

      optional argument to be used as this when invoking the action

    Returns Promise<void>

  • Perform the given action for each entry selected by the specified key set until all entries have been processed or the action raises an error.

    Errors raised by the action are relayed to the caller.

    The implementation processes each entry on the client and should only be used for read-only client-side operations (such as adding map entries to a UI widget, for example).

    Any entry mutation caused by the specified action will not be propagated to the server when this method is called on a distributed map, so it should be avoided. The mutating operations on a subset of entries should be implemented using invokeAll.

    Parameters

    • action: (value: V, key: K, map: NamedMap<K, V>) => void

      the action to be performed for each entry

        • (value: V, key: K, map: NamedMap<K, V>): void
        • Parameters

          Returns void

    • keys: Iterable<K>

      the keys to process these keys are not required to exist within the Map

    • Optional thisArg: any

      optional argument to be used as this when invoking the action

    Returns Promise<void>

  • Perform the given action for each entry selected by the specified key set until all entries have been processed or the action raises an error.

    Errors raised by the action are relayed to the caller.

    The implementation processes each entry on the client and should only be used for read-only client-side operations (such as adding map entries to a UI widget, for example).

    Any entry mutation caused by the specified action will not be propagated to the server when this method is called on a distributed map, so it should be avoided. The mutating operations on a subset of entries should be implemented using invokeAll.

    Parameters

    • action: (value: V, key: K, map: NamedMap<K, V>) => void

      the action to be performed for each entry

        • (value: V, key: K, map: NamedMap<K, V>): void
        • Parameters

          Returns void

    • filter: Filter

      the filter criteria to apply to the entries

    • Optional thisArg: any

      optional argument to be used as this when invoking the action

    Returns Promise<void>

get

  • get(key: K): Promise<V | null>
  • Returns the value to which this cache maps the specified key.

    Parameters

    • key: K

      the key whose associated value is to be returned

    Returns Promise<V | null>

    a Promise resolving the value to which the specified key is mapped, or null if this map contains no mapping for the key

getAll

  • getAll(keys: Iterable<K>): Promise<Map<K, V>>
  • Get all the specified keys, if they are in the map. For each key that is in the map, that key and its corresponding value will be placed in the map that is returned by this method. The absence of a key in the returned map indicates that it was not in the cache, which may imply (for caches that can load behind the scenes) that the requested data could not be loaded.

    Parameters

    • keys: Iterable<K>

      an Iterable of keys that may be in this map

    Returns Promise<Map<K, V>>

    a Promiseresolving to a Map of keys to values for the specified keys passed in keys

getOrDefault

  • getOrDefault(key: K, defaultValue: V): Promise<V | null>
  • Returns the value to which the specified key is mapped, or the specified defaultValue if this map contains no mapping for the key.

    Parameters

    • key: K
    • defaultValue: V

    Returns Promise<V | null>

    the value to which the specified key is mapped, or the specified defaultValue if this map contains no mapping for the key

has

  • has(key: K): Promise<boolean>
  • Returns true if the specified key is mapped a value within the cache.

    Parameters

    • key: K

      the key whose presence in this cache is to be tested

    Returns Promise<boolean>

    a Promise resolving to true if the key is mapped to a value, or false if it does not

hasEntry

  • hasEntry(key: K, value: V): Promise<boolean>
  • Returns true if the specified key is mapped to the specified value within the cache.

    Parameters

    • key: K

      the key

    • value: V

      the value

    Returns Promise<boolean>

    a Promise resolving to true if the key is mapped to the specified value value, or false if it does not

hasValue

  • hasValue(value: V): Promise<boolean>
  • Returns true if the specified value is mapped to some key.

    Parameters

    • value: V

      the value expected to be associated with some key

    Returns Promise<boolean>

    a Promise resolving to true if a mapping exists, or false if it does not

invoke

  • invoke<R>(key: K, processor: EntryProcessor<K, V, R>): Promise<R | null>
  • Invoke the passed EntryProcessor against the {@link Entry} specified by the passed key, returning the result of the invocation.

    Type parameters

    Parameters

    • key: K

      the key to process it is not required to exist within the Map

    • processor: EntryProcessor<K, V, R>

      the EntryProcessor to use to process the specified key

    Returns Promise<R | null>

    the result of the invocation as returned from the EntryProcessor

invokeAll

  • invokeAll<R>(processor: EntryProcessor<K, V, R>): Promise<Map<K, R>>
  • invokeAll<R>(keys: Iterable<K>, processor: EntryProcessor<K, V, R>): Promise<Map<K, R>>
  • invokeAll<R>(filter: Filter, processor: EntryProcessor<K, V, R>): Promise<Map<K, R>>
  • Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.

    Type parameters

    Parameters

    Returns Promise<Map<K, R>>

    a Map containing the results of invoking the EntryProcessor against each of the specified keys

  • Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.

    Type parameters

    Parameters

    • keys: Iterable<K>

      the keys to process these keys are not required to exist within the Map

    • processor: EntryProcessor<K, V, R>

      the EntryProcessor to use to process the specified keys

    Returns Promise<Map<K, R>>

  • Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.

    Unless specified otherwise, implementations will perform this operation in two steps: 1. use the filter to retrieve a matching entry set 2. apply the agent to every filtered entry.

    This algorithm assumes that the agent's processing does not affect the result of the specified filter evaluation, since the filtering and processing could be performed in parallel on different threads. If this assumption does not hold, the processor logic has to be idempotent, or at least re-evaluate the filter. This could be easily accomplished by wrapping the processor with the ConditionalProcessor.

    Type parameters

    Parameters

    Returns Promise<Map<K, R>>

keys

  • Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map.

    Returns Promise<RemoteSet<K>>

    a set view of the keys contained in this map

  • Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.

    Unlike the {@link keySet()} method, the set returned by this method may not be backed by the map, so changes to the set may not reflected in the map, and vice-versa.

    Parameters

    • filter: Filter

      the Filter object representing the criteria that the entries of this map should satisfy

    • Optional comparator: Comparator

      the comparator for sorting

    Returns Promise<RemoteSet<K>>

    a set of keys for entries that satisfy the specified criteria

on

  • Allows registration of a handler to be notified of cache lifecycle events.

    Parameters

    • eventName: RELEASED | TRUNCATED | DESTROYED

      the event

    • handler: (cacheName: string) => void

      the event handler

        • (cacheName: string): void
        • Parameters

          • cacheName: string

          Returns void

    Returns void

release

  • release(): Promise<void>
  • Release local resources associated with instance.

    Returns Promise<void>

removeIndex

  • Remove an index from this NamedMap.

    Removes an index to this NamedMap. Example:

    cache.removeIndex(Extractors.extract('name'))

    Parameters

    • extractor: ValueExtractor

      The ValueExtractor object that is used to extract an indexable Object from a value stored in the indexed Map. Must not be null.

    Returns Promise<void>

    A Promise that resolves when the operation completes.

removeMapListener

  • Remove a standard map listener that previously signed up for all events. This has the same result as the following call:

    Parameters

    Returns Promise<void>

removeMapping

  • removeMapping(key: K, value: V): Promise<boolean>
  • Removes the entry for the specified key only if it is currently mapped to the specified value.

    Parameters

    • key: K

      key with which the specified value is associated

    • value: V

      expected to be associated with the specified key

    Returns Promise<boolean>

    a Promiseresolving to true if the value was removed

replace

  • replace(key: K, value: V): Promise<V | null>
  • Replaces the entry for the specified key only if it is currently mapped to some value.

    Parameters

    • key: K

      key with which the specified value is associated

    • value: V

      value to be associated with the specified key

    Returns Promise<V | null>

    a Promise resolving to the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)

replaceMapping

  • replaceMapping(key: K, oldValue: V, newValue: V): Promise<boolean>
  • Replaces the entry for the specified key only if currently mapped to the specified value.

    Parameters

    • key: K

      key whose associated value is to be removed

    • oldValue: V

      value expected to be associated with the specified key

    • newValue: V

      value to be associated with the specified key

    Returns Promise<boolean>

    a Promise resolving to true if the value was replaced

set

  • set(key: K, value: V): Promise<V | null>
  • Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.

    Parameters

    • key: K

      the key with which the specified value is to be associated

    • value: V

      the value to be associated with the specified key

    Returns Promise<V | null>

    a Promise resolving to the previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values

setIfAbsent

  • setIfAbsent(key: K, value: V): Promise<V | null>
  • If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value.

    Parameters

    • key: K

      the key with which the specified value is to be associated

    • value: V

      the value to be associated with the specified key

    Returns Promise<V | null>

    a Promise resolving to the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)

truncate

  • truncate(): Promise<void>
  • Truncates the cache. Unlike clear, this function does not generate an event for each removed entry.

    Returns Promise<void>

    a Promise which resolves once the operation is complete

values

  • Returns a Set view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined.

    Returns Promise<RemoteSet<V>>

    a Promise that resolves to the values in the set

  • Return a Set of the values contained in this map that satisfy the criteria expressed by the filter.

    Unlike the `values()` method, the collection returned by this method may not be backed by the map, so changes to the collection may not be reflected in the map, and vice-versa.

    Parameters

    • filter: Filter

      the Filter object representing the criteria that the entries of this map should satisfy

    • Optional comparator: Comparator

      the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be used

    Returns Promise<RemoteSet<V>>

    a Promise that resolves to the values in the set that satisfy the specified criteria