perf(server): Cache user keypair
This commit is contained in:
parent
202e943d55
commit
7c3086e9d9
5 changed files with 21 additions and 15 deletions
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));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue