Class MaxKeyLengthStorage<T>

A KeyValueStorage that hashes keys in case they would be longer than the set limit. Hashed keys are prefixed with a certain value to prevent issues with incoming keys that are already hashed. The default max length is 150 and the default prefix is $hash$.

This class mostly exists to prevent issues when writing storage entries to disk. Keys that are too long would cause issues with the file name limit. For this reason, only the part after the last / in a key is hashed, to preserve the expected file structure.

Type Parameters

  • T

Implements

Constructors

Properties

hashPrefix: string
logger: Logger = ...
maxKeyLength: number
source: KeyValueStorage<string, Entry<T>>

Methods

  • Similar to getKey but checks to make sure the key does not already contain the prefix. Only necessary for set calls.

    Parameters

    • key: string

    Returns string