Johann150
101ea21747
Some checks failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/test Pipeline failed
If the cache runs for an infinite amount of time, the users may as well be stored in memory directly. Changelog: Fixed
15 lines
468 B
TypeScript
15 lines
468 B
TypeScript
import { UserKeypairs } from '@/models/index.js';
|
|
import { User } from '@/models/entities/user.js';
|
|
import { UserKeypair } from '@/models/entities/user-keypair.js';
|
|
import { Cache } from './cache.js';
|
|
import { MINUTE } from '@/const.js';
|
|
|
|
const cache = new Cache<UserKeypair>(
|
|
15 * MINUTE,
|
|
(userId) => UserKeypairs.findOneByOrFail({ userId }),
|
|
);
|
|
|
|
export async function getUserKeypair(userId: User['id']): Promise<UserKeypair> {
|
|
return await cache.fetch(userId);
|
|
}
|