From d0e75d5948f215d5f7d4b7f80ae90861c73c42be Mon Sep 17 00:00:00 2001 From: Weiko Date: Thu, 4 Dec 2025 15:49:17 +0100 Subject: [PATCH] fix cache service mset (#16327) pipeline.exec() is a a blocking operation which means if we want to write a large chunk of data (or many maps in our case) it will block write operations and impact performances. We prefer to simply call set multiple times in a promise.all, this is an acceptable tradeoff --- .../services/cache-storage.service.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/cache-storage/services/cache-storage.service.ts b/packages/twenty-server/src/engine/core-modules/cache-storage/services/cache-storage.service.ts index 23519d9102..65d96afbee 100644 --- a/packages/twenty-server/src/engine/core-modules/cache-storage/services/cache-storage.service.ts +++ b/packages/twenty-server/src/engine/core-modules/cache-storage/services/cache-storage.service.ts @@ -67,20 +67,7 @@ export class CacheStorageService { async mset( entries: Array<{ key: string; value: T; ttl?: Milliseconds }>, ): Promise { - if (this.isRedisCache()) { - const pipeline = (this.cache as RedisCache).store.client.multi(); - - entries.forEach(({ key, value, ttl }) => { - const prefixedKey = this.getKey(key); - - pipeline.set(prefixedKey, JSON.stringify(value)); - if (ttl) { - pipeline.expire(prefixedKey, Math.floor(ttl / 1000)); - } - }); - - await pipeline.exec(); - + if (entries.length === 0) { return; }