The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Use pipeline to count event stream (#17450)
Thomas Trompette570f83ea761e
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.tsindex 63a33800265..b2b32d67506 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@@ -227,11 +227,20 @@ export class CacheStorageService {const keys = result.keys;if (keys.length > 0) {- const counts = await Promise.all(- keys.map((key) => redisClient.sCard(key)),- );+ const pipeline = redisClient.multi();++ for (const key of keys) {+ pipeline.sCard(key);+ }- totalCount += counts.reduce((sum, count) => sum + count, 0);+ const results = await pipeline.exec();++ for (const result of results) {+ if (result instanceof Error) {+ throw result;+ }+ totalCount += result as number;+ }}} while (cursor !== 0);