Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MegaCache

It's the flagship cache of the library.

An LRU in-memory cache backed by a LRUBinning file system cache.

Make sure to close() after use to remove the cache files.

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new MegaCache(__namedParameters: { cacheDir: string; maxFSEntriesPerBin: number; maxFSSizePerBin: number; maxMemoryDataSize: number; minFSBinWritablePortion: number; source: CacheSource }): MegaCache
  • Parameters

    • __namedParameters: { cacheDir: string; maxFSEntriesPerBin: number; maxFSSizePerBin: number; maxMemoryDataSize: number; minFSBinWritablePortion: number; source: CacheSource }
      • cacheDir: string

        Where to store files on disk

      • maxFSEntriesPerBin: number

        How many files max to store on disk per bin before rotation. We can store upto 3x this.

      • maxFSSizePerBin: number

        How large a file bin can be on disk before rotation. We can store upto 3x this.

      • maxMemoryDataSize: number

        The maximum amount of RAM to use for caching

      • minFSBinWritablePortion: number

        A configuration option for the LRUBinning cache algorithm. Sets the minimum portion of items to be cleared between cache rotations. There must be space available in order for cache fills to occur.

      • source: CacheSource

        A cacheSource to fallback to.

    Returns MegaCache

Properties

cacheType

cacheType: "async" = "async"

stack

Accessors

count

  • get count(): number
  • Returns number

dataSize

  • get dataSize(): number

Methods

close

  • close(): Promise<void>

delete

  • delete(key: string | Buffer): Promise<void>

get

  • get(key: string): Promise<Buffer | undefined>
  • Parameters

    • key: string

    Returns Promise<Buffer | undefined>

set

  • set(key: string, value: Buffer): Promise<void>
  • Parameters

    • key: string
    • value: Buffer

    Returns Promise<void>

Generated using TypeDoc