perf(server): Cache user keypair
This commit is contained in:
10
src/misc/keypair-store.ts
Normal file
10
src/misc/keypair-store.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { UserKeypairs } from '../models';
|
||||
import { User } from '../models/entities/user';
|
||||
import { UserKeypair } from '../models/entities/user-keypair';
|
||||
import { Cache } from './cache';
|
||||
|
||||
const cache = new Cache<UserKeypair>(Infinity);
|
||||
|
||||
export async function getUserKeypair(userId: User['id']): Promise<UserKeypair> {
|
||||
return await cache.fetch(userId, async () => await UserKeypairs.findOneOrFail(userId));
|
||||
}
|
Reference in New Issue
Block a user