Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NamedCacheClient<K, V>

Class NamedCacheClient is a client to a NamedCache which is a Map that holds resources shared among members of a cluster.

All methods in this class return a Promise that eventually either resolves to a value (as described in the NamedCache) or an error if any exception occurs during the method invocation.

This class also extends EventEmitter and emits the following events:

  1. MapLifecycleEvent.DESTROYED: when the underlying cache is destroyed
  2. MapLifecycleEvent.TRUNCATED: when the underlying cache is truncated
  3. MapLifecycleEvent.RELEASED: when the underlying cache is released

Type parameters

  • K = any

    the type of the cache keys

  • V = any

    the type of the cache values

Hierarchy

  • EventEmitter
    • NamedCacheClient

Implements

Index

Constructors

constructor

  • Create a new NamedCacheClient with the specified address and cache name.

    Parameters

    • cacheName: string

      the name of the coherence NamedCache

    • session: Session

      the session with the Coherence cluster

    • serializer: Serializer

      the serializer used to ser/deser messages

    Returns NamedCacheClient

Properties

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

active

  • get active(): boolean
  • true if this cache is active.

    inheritdoc

    Returns boolean

destroyed

  • get destroyed(): boolean
  • Signifies whether or not this NamedMap has been destroyed.

    inheritdoc

    Returns boolean

empty

  • get empty(): Promise<boolean>
  • true if this map contains no key-value mappings.

    inheritdoc

    Returns Promise<boolean>

name

  • get name(): string
  • The name of this NamedMap.

    inheritdoc

    Returns string

released

  • get released(): boolean
  • true if this cache has been released

    inheritdoc

    Returns boolean

size

  • get size(): Promise<number>
  • Signifies the number of key-value mappings in this map.

    inheritdoc

    Returns Promise<number>

    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.

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

addMapListener

  • addMapListener(listener: MapListener<K, V>, keyOrFilterOrLite?: Filter | K | boolean, isLite?: boolean): Promise<void>
  • inheritdoc

    Parameters

    • listener: MapListener<K, V>
    • Optional keyOrFilterOrLite: Filter | K | boolean
    • Optional isLite: boolean

    Returns Promise<void>

aggregate

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>
  • inheritdoc

    Parameters

    • key: K

    Returns Promise<V>

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>

Protected doInvokeAll

  • doInvokeAll<T>(call: EventEmitter): Promise<Map<K, T>>
  • Helper function for invokeAll calls.

    Type parameters

    • T = any

    Parameters

    • call: EventEmitter

      gRPC call/event emitter

    Returns Promise<Map<K, T>>

    a Promise eventually resolving to Map containing the results of performing the invokeAll operation

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

entries

  • 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

    • Optional filter: Filter

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

    • Optional comp: 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

eventNames

  • eventNames(): Array<string | symbol>

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>
  • Parameters

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

          Returns void

    • Optional thisArg: any

    Returns Promise<void>

  • Parameters

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

          Returns void

    • keys: Iterable<K>
    • Optional thisArg: any

    Returns Promise<void>

  • Parameters

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

          Returns void

    • filter: Filter
    • Optional thisArg: any

    Returns Promise<void>

get

  • get(key: K): Promise<V | null>
  • inheritdoc

    Parameters

    • key: K

    Returns Promise<V | null>

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

getMaxListeners

  • getMaxListeners(): number

getOrDefault

  • getOrDefault(key: K, defaultValue: V | null): Promise<V | null>
  • inheritdoc

    Parameters

    • key: K
    • defaultValue: V | null

    Returns Promise<V | null>

getRequestFactory

  • getRequestFactory(): RequestFactory<K, V>
  • Internal method to return RequestFactory.

    Returns RequestFactory<K, V>

    An instance of RequestFactory

getSerializer

has

  • has(key: K): Promise<boolean>
  • inheritdoc

    Parameters

    • key: K

    Returns Promise<boolean>

hasEntry

  • hasEntry(key: K, value: V): Promise<boolean>
  • inheritdoc

    Parameters

    • key: K
    • value: V

    Returns Promise<boolean>

hasValue

  • hasValue(value: V): Promise<boolean>
  • inheritdoc

    Parameters

    • value: V

    Returns Promise<boolean>

invoke

  • invoke<R>(key: K, processor: EntryProcessor<K, V, R>): Promise<R | null>
  • inheritdoc

    Type parameters

    • R = any

    Parameters

    Returns Promise<R | null>

invokeAll

  • inheritdoc

    Type parameters

    • R = any

    Parameters

    Returns Promise<Map<K, R>>

keys

  • 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

    • Optional 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

listenerCount

  • listenerCount(type: string | symbol): number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

nextEntrySetPage

  • nextEntrySetPage(cookie: Uint8Array | string | undefined): ClientReadableStream<EntryResult>
  • Obtain the next page of entries from the cache.

    Parameters

    • cookie: Uint8Array | string | undefined

      an opaque cookie for page tracking

    Returns ClientReadableStream<EntryResult>

    a {@link ClientReadableStream} to read entries from

nextKeySetPage

  • nextKeySetPage(cookie: Uint8Array | string | undefined): ClientReadableStream<BytesValue>
  • Obtain the next page of keys from the cache.

    Parameters

    • cookie: Uint8Array | string | undefined

      an opaque cookie for page tracking

    Returns ClientReadableStream<BytesValue>

    a {@link ClientReadableStream} to read keys from

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]

release

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

    Returns Promise<void>

removeAllListeners

  • removeAllListeners(event?: string | symbol): this

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.

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

removeMapListener

  • inheritdoc

    Parameters

    Returns Promise<void>

removeMapping

  • removeMapping(key: K, value: V): Promise<boolean>
  • inheritdoc

    Parameters

    • key: K
    • value: V

    Returns Promise<boolean>

replace

  • replace(key: K, value: V): Promise<V>
  • inheritdoc

    Parameters

    • key: K
    • value: V

    Returns Promise<V>

replaceMapping

  • replaceMapping(key: K, value: V, newValue: V): Promise<boolean>
  • inheritdoc

    Parameters

    • key: K
    • value: V
    • newValue: V

    Returns Promise<boolean>

Protected resolveValue

  • resolveValue<T>(resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void, err?: ServiceError | null, fn?: () => T | undefined): void
  • Resolve a promise.

    Type parameters

    • T

    Parameters

    • resolve: (value?: T | PromiseLike<T>) => void

      resolution callback handler

        • (value?: T | PromiseLike<T>): void
        • Parameters

          • Optional value: T | PromiseLike<T>

          Returns void

    • reject: (reason?: any) => void

      failure callback handler

        • (reason?: any): void
        • Parameters

          • Optional reason: any

          Returns void

    • Optional err: ServiceError | null

      raised error, if any

    • Optional fn: () => T | undefined

      callback for obtaining a resolution value

        • (): T | undefined
        • Returns T | undefined

    Returns void

set

  • set(key: K, value: V, ttl?: number): Promise<V>
  • inheritdoc

    Parameters

    • key: K
    • value: V
    • Optional ttl: number

    Returns Promise<V>

setIfAbsent

  • setIfAbsent(key: K, value: V, ttl?: number): Promise<V>
  • inheritdoc

    Parameters

    • key: K
    • value: V
    • Optional ttl: number

    Returns Promise<V>

setMaxListeners

  • setMaxListeners(n: number): this

Protected setupEventHandlers

  • setupEventHandlers(): void
  • Initialize event handlers for this client.

    Returns void

Protected toValue

  • toValue<V>(value: Uint8Array): V
  • Deserializes the provided bytes.

    Type parameters

    • V

    Parameters

    • value: Uint8Array

      bytes to decode

    Returns V

    the deserialized value

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

  • 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

    • Optional 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

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number