The type of the label for the key (e.g. string, MetricName, …)
The type of value to be stored in the hash table (e.g. MetricCompute, string, …)
Creates an instance of HashTable.
The type of the label for the key (e.g. string, MetricName, …)
The type of value to be stored in the hash table (e.g. MetricCompute, string, …)
OptionalLRU: boolean = trueWhether to use Least Recently Used (LRU) eviction policy
Private ReadonlyLRUWhether to use Least Recently Used (LRU) eviction policy
PrivatetableThe internal map to store entries. The key is a string generated from the label and any number of hashed strings. The value is of type T.
Private Static ReadonlyMAX_The max. length of a string to hash, which is set to 2048 characters
Private Static ReadonlyTABLE_The max. size of the hash table, which is set to 10,000
Clears the hash table. This method removes all entries from the hash table.
Deletes an entry from the hash table by its key.
The key of the entry to delete
Retrieves the entry from the hash table by its key.
The key to look up
Checks if a key exists in the hash table.
The key to check
Generates a unique hash key for any number of string arguments. Return false if any string exceeds the maximum length. The key is in the format "label-H1-H2-H3-..."
Label for this key (e.g. metric name, normalization flags, …)
Array of strings to hash (e.g. input, params, …)
Optionalsorted: boolean = falseWhether to sort the hashes before creating the key
Adds an entry to the hash table. If the table is full, it evicts the least recently used entry (if LRU is enabled).
The hashed key for the entry
The entry itself to add
Optionalupdate: boolean = trueWhether to update the entry if it already exists
Returns the current size of the hash table.
HashTable class implements an instantiable hash table/cache. Allows for multiple independent caches with type safety and high performance.