20 lines
454 B
TypeScript
20 lines
454 B
TypeScript
import { LRUCache } from "lru-cache";
|
|
import { AuthenticatedUser } from "../auth";
|
|
|
|
const sessionCache = new LRUCache<string, AuthenticatedUser>({
|
|
max: 100,
|
|
ttl: 1000 * 60 * 60,
|
|
});
|
|
|
|
export function cacheSession(key: string, user: AuthenticatedUser) {
|
|
sessionCache.set(key, user);
|
|
}
|
|
|
|
export function getCachedSession(key: string) {
|
|
return sessionCache.get(key);
|
|
}
|
|
|
|
export function removeCachedSession(key: string) {
|
|
sessionCache.delete(key);
|
|
}
|