summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel <34555296+Flam3rboy@users.noreply.github.com>2023-03-30 18:26:19 +0200
committerSamuel <34555296+Flam3rboy@users.noreply.github.com>2023-03-30 18:26:19 +0200
commitc8f65ca4c73d27455817be1512a2da3277c7efc0 (patch)
treeafe9f4b696e2867ec48c8a277cff4999dcb7f0ac
parentMerge pull request #1008 from spacebarchat/dev/samuel (diff)
downloadserver-c8f65ca4c73d27455817be1512a2da3277c7efc0.tar.xz
fix: disable cache if multi threaded
-rw-r--r--src/util/cache/EntityCache.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util/cache/EntityCache.ts b/src/util/cache/EntityCache.ts
index 9135fef3..ba1e5bd8 100644
--- a/src/util/cache/EntityCache.ts
+++ b/src/util/cache/EntityCache.ts
@@ -24,7 +24,7 @@ import {
 } from "typeorm";
 import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
 import { BaseClassWithId } from "../entities/BaseClass";
-import { Config, getDatabase } from "../util";
+import { Config, getDatabase, RabbitMQ } from "../util";
 import { CacheManager } from "./Cache";
 
 function getObjectKeysAsArray(obj?: Record<string, any>) {
@@ -52,7 +52,9 @@ class BaseEntityCache extends BaseClassWithId {
 
 	static useDataSource(dataSource: DataSource | null) {
 		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 (!this.cacheEnabled) return;
 		this.cache = new CacheManager();