summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/MetaService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-09-19 03:11:50 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-09-19 03:11:50 +0900
commita2eac9fff67f811ed4ac1a80a88fd1f0eafae6c8 (patch)
tree9c7190e05fe0ffe085646cd194c6c65d47375f83 /packages/backend/src/core/MetaService.ts
parentrevert (diff)
downloadsharkey-a2eac9fff67f811ed4ac1a80a88fd1f0eafae6c8.tar.gz
sharkey-a2eac9fff67f811ed4ac1a80a88fd1f0eafae6c8.tar.bz2
sharkey-a2eac9fff67f811ed4ac1a80a88fd1f0eafae6c8.zip
test
Diffstat (limited to 'packages/backend/src/core/MetaService.ts')
-rw-r--r--packages/backend/src/core/MetaService.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/backend/src/core/MetaService.ts b/packages/backend/src/core/MetaService.ts
index b5bd423765..4099e340be 100644
--- a/packages/backend/src/core/MetaService.ts
+++ b/packages/backend/src/core/MetaService.ts
@@ -7,24 +7,24 @@ import type { OnApplicationShutdown } from '@nestjs/common';
@Injectable()
export class MetaService implements OnApplicationShutdown {
- #cache: Meta | undefined;
- #intervalId: NodeJS.Timer;
+ private cache: Meta | undefined;
+ private intervalId: NodeJS.Timer;
constructor(
@Inject(DI.db)
private db: DataSource,
) {
if (process.env.NODE_ENV !== 'test') {
- this.#intervalId = setInterval(() => {
+ this.intervalId = setInterval(() => {
this.fetch(true).then(meta => {
- this.#cache = meta;
+ this.cache = meta;
});
}, 1000 * 10);
}
}
async fetch(noCache = false): Promise<Meta> {
- if (!noCache && this.#cache) return this.#cache;
+ if (!noCache && this.cache) return this.cache;
return await this.db.transaction(async transactionalEntityManager => {
// 過去のバグでレコードが複数出来てしまっている可能性があるので新しいIDを優先する
@@ -37,7 +37,7 @@ export class MetaService implements OnApplicationShutdown {
const meta = metas[0];
if (meta) {
- this.#cache = meta;
+ this.cache = meta;
return meta;
} else {
// metaが空のときfetchMetaが同時に呼ばれるとここが同時に呼ばれてしまうことがあるのでフェイルセーフなupsertを使う
@@ -51,13 +51,13 @@ export class MetaService implements OnApplicationShutdown {
)
.then((x) => transactionalEntityManager.findOneByOrFail(Meta, x.identifiers[0]));
- this.#cache = saved;
+ this.cache = saved;
return saved;
}
});
}
public onApplicationShutdown(signal?: string | undefined) {
- clearInterval(this.#intervalId);
+ clearInterval(this.intervalId);
}
}