add cache to auth
This commit is contained in:
19
src/utils/cache.ts
Normal file
19
src/utils/cache.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user