Files
web/packages/common/dataCache/MemoryCache/InMemoryCache/set.ts
Anton Gunnarsson 048a477e52 Merged in feat/common-package (pull request #2333)
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
2025-06-11 13:08:39 +00:00

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,
})
}