diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-22 15:14:54 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-22 15:14:54 +0900 |
| commit | 7c3086e9d9508d5df03d7859932c766a26b9664e (patch) | |
| tree | ddb4da56c3a14fdb6115c91290dd58d1111ef51b /src/misc | |
| parent | tweak cache lifetime (diff) | |
| download | sharkey-7c3086e9d9508d5df03d7859932c766a26b9664e.tar.gz sharkey-7c3086e9d9508d5df03d7859932c766a26b9664e.tar.bz2 sharkey-7c3086e9d9508d5df03d7859932c766a26b9664e.zip | |
perf(server): Cache user keypair
Diffstat (limited to 'src/misc')
| -rw-r--r-- | src/misc/keypair-store.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/misc/keypair-store.ts b/src/misc/keypair-store.ts new file mode 100644 index 0000000000..43f451110c --- /dev/null +++ b/src/misc/keypair-store.ts @@ -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)); +} |