feat: Add common package * Add isEdge, safeTry and dataCache to new common package * Add eslint and move prettier config * Fix yarn lock * Clean up tests * Add lint-staged config to common * Add missing dependencies Approved-by: Joakim Jäderberg
14 lines
307 B
TypeScript
14 lines
307 B
TypeScript
import { type CacheTime, getCacheTimeInSeconds } from "../../Cache"
|
|
import { cacheMap } from "./cacheMap"
|
|
|
|
export async function set<T>(
|
|
key: string,
|
|
data: T,
|
|
ttl: CacheTime
|
|
): Promise<void> {
|
|
cacheMap.set(key, {
|
|
data: data,
|
|
expiresAt: Date.now() + getCacheTimeInSeconds(ttl) * 1000,
|
|
})
|
|
}
|