Options
All
  • Public
  • Public/Protected
  • All
Menu

A variant of the LRU cache where this cache stores mappings from keys to file paths. This throws out least recently used items when adding a new file path to cache. Thrown out items are removed from cache and the file it pointed to is deleted

Hierarchy

  • LRUFileCache

Index

Constructors

constructor

  • new LRUFileCache(max: number, cachePath: string): LRUFileCache

Properties

Private cache

cache: Map<string, LRUFileCacheNode> = new Map()

cachePath

cachePath: string

max

max: number

queueHead

queueHead: LRUFileCacheNode = null

queueTail

queueTail: LRUFileCacheNode = null

size

size: number = 0

Methods

add

  • add(key: string, filepath: string): Promise<string>
  • Adds key to file path pair to cache and copies file to new location. Does not delete the given file at filepath

    Automatically throws out least recently used items if not enough space left to fit new file

    Resolves with path to cached file location

    Parameters

    • key: string

      the key pointing to the given file path

    • filepath: string

      the file path representing the file to cache

    Returns Promise<string>

get

  • get(key: string): string

Private getCachedFilePath

  • getCachedFilePath(filepath: string, key: string): string

has

  • has(key: string): boolean

Generated using TypeDoc