server: limit caching time for public keys

This commit is contained in:
Johann150 2023-07-19 09:43:17 +02:00
parent 456a86af8d
commit 75ab4de41f
Signed by: Johann150
GPG Key ID: 9EE6577A2A06F8F1
1 changed files with 3 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import { UserPublickey } from '@/models/entities/user-publickey.js';
import { uriPersonCache, userByIdCache } from '@/services/user-cache.js';
import { createPerson } from '@/remote/activitypub/models/person.js';
import { Resolver } from '@/remote/activitypub/resolver.js';
import { HOUR } from '@/const.js';
export type AuthUser = {
user: IRemoteUser;
@ -12,11 +13,11 @@ export type AuthUser = {
};
const publicKeyCache = new Cache<UserPublickey>(
Infinity,
2 * HOUR,
(keyId) => UserPublickeys.findOneBy({ keyId }).then(x => x ?? undefined),
);
const publicKeyByUserIdCache = new Cache<UserPublickey>(
Infinity,
2 * HOUR,
(userId) => UserPublickeys.findOneBy({ userId }).then(x => x ?? undefined),
);