-
Notifications
You must be signed in to change notification settings - Fork 59
/
cache.ts
31 lines (28 loc) · 1011 Bytes
/
cache.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const cache: Map<string, unknown> = new Map()
/**
* Saves a value in the cache with the specified key.
*
* @param {string} key - The key to associate with the value in the cache.
* @param {unknown} value - The value to be saved in the cache.
*/
export function saveCache(key: string, value: unknown): void {
cache.set(key, value)
}
/**
* Retrieves the value associated with the specified key from the cache.
*
* @param {string} key - The key of the value to retrieve from the cache.
* @returns {unknown} The value associated with the specified key, or undefined if the key does not exist in the cache.
*/
export function getCache(key: string): unknown {
return cache.get(key)
}
/**
* Removes the value associated with the specified key from the cache.
*
* @param {string} key - The key of the value to remove from the cache.
* @returns {void} The removed value, or undefined if the key does not exist in the cache.
*/
export function removeCache(key: string): void {
cache.delete(key)
}