Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Cache<Data, Options>

Provides a way to retrieve and access conversation formations. Has configurable limits on the number of formations that are stored. If the provider has support, the cache will preload future messages.

Type parameters

  • Data

  • Options

Hierarchy

  • Cache

Implements

Index

Constructors

constructor

  • new Cache(__namedParameters: object): Cache

Properties

provider

provider: IProvider<Data, Options>

The provider that is used to find messages when they are not in the cache

Static limit

limit: number = 128

The default limit size

Accessors

limit

  • get limit(): number
  • set limit(value: number): void
  • The maximum number of messages that are allowed to be stored in the cache

    Returns number

  • Sets the maximum number of messages that are allowed to be stored in the cache

    Parameters

    • value: number

    Returns void

size

  • get size(): number

Methods

__@iterator

  • The stored IDs and formations

    Returns IterableIterator<[string, IFormationImmutable<Data>]>

    an iterator that will walk through the stored formations

__@toStringTag

  • __@toStringTag(): string
  • The string to use for the default toString function

    Returns string

clear

  • clear(): void

entries

  • The stored IDs and formations

    Returns IterableIterator<[string, IFormationImmutable<Data>]>

    an iterator that will walk through the stored formations

fetch

  • Retrieves a formation by ID

    throws

    { RangeError } failed to find the formation

    Parameters

    • id: GuidAccepted

      the globally unique identification value of the formation to retrieve

    • Optional options: Options

      the provider options

    Returns Promise<IFormationImmutable<Data>>

    the found formation

forEach

  • forEach(callback: function, thisArg: any): void
  • Invokes a callback on each entry in the cache, undeterminate order

    Parameters

    Returns void

get

  • Retrieves a cached formation

    Parameters

    • id: GuidAccepted

      the globally unique identification value to retrieve

    Returns IFormationImmutable<Data> | undefined

    the formation or undefined if not found

has

  • has(id: GuidAccepted): boolean
  • Determines if the cache has a certain formation stored

    Parameters

    • id: GuidAccepted

      the globally unique identification value to search for

    Returns boolean

    true if the formation is available

keys

  • keys(): IterableIterator<string>
  • The stored formation identification values

    Returns IterableIterator<string>

    an iterator that will walk through the stored IDs

Protected miss

  • Invoked when a fetch call fails to find the target GUID in the cache

    Parameters

    • id: Guid

      the GUID to retrieve

    • Optional options: Options

      the provider options

    Returns AsyncIterableIterator<IFormationImmutable<Data>>

    the provider formations

shrink

  • shrink(size: number): void
  • Shrinks the cache to a certain size

    Parameters

    • size: number

    Returns void

Protected store

toJSON

  • toJSON(_?: string): Array<string>
  • Converts the cache into it's JSON representation

    Parameters

    • Default value _: string = ""

    Returns Array<string>

    the object to serialize with JSON.stringify

values