fix: disable cache if multi threaded
This commit is contained in:
parent
69ea71aa9e
commit
c8f65ca4c7
6
src/util/cache/EntityCache.ts
vendored
6
src/util/cache/EntityCache.ts
vendored
@ -24,7 +24,7 @@ import {
|
|||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
|
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
|
||||||
import { BaseClassWithId } from "../entities/BaseClass";
|
import { BaseClassWithId } from "../entities/BaseClass";
|
||||||
import { Config, getDatabase } from "../util";
|
import { Config, getDatabase, RabbitMQ } from "../util";
|
||||||
import { CacheManager } from "./Cache";
|
import { CacheManager } from "./Cache";
|
||||||
|
|
||||||
function getObjectKeysAsArray(obj?: Record<string, any>) {
|
function getObjectKeysAsArray(obj?: Record<string, any>) {
|
||||||
@ -52,7 +52,9 @@ class BaseEntityCache extends BaseClassWithId {
|
|||||||
|
|
||||||
static useDataSource(dataSource: DataSource | null) {
|
static useDataSource(dataSource: DataSource | null) {
|
||||||
super.useDataSource(dataSource);
|
super.useDataSource(dataSource);
|
||||||
this.cacheEnabled = Config.get().cache.enabled ?? true;
|
const isMultiThreaded =
|
||||||
|
process.env.EVENT_TRANSMISSION === "process" || RabbitMQ.connection;
|
||||||
|
this.cacheEnabled = Config.get().cache.enabled ?? !isMultiThreaded;
|
||||||
if (Config.get().cache.redis) return; // TODO: Redis cache
|
if (Config.get().cache.redis) return; // TODO: Redis cache
|
||||||
if (!this.cacheEnabled) return;
|
if (!this.cacheEnabled) return;
|
||||||
this.cache = new CacheManager();
|
this.cache = new CacheManager();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user