@mastra/redis 1.4.5 → 1.4.6-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -572,15 +572,14 @@ var StoreMemoryRedis = class extends MemoryStorage {
572
572
  perPage: perPageForResponse,
573
573
  hasMore: false
574
574
  };
575
+ const perThreadIds = await Promise.all(threadIds.map((tid) => this.client.zRange(getThreadMessagesKey(tid), 0, -1)));
575
576
  const allMessageIdsWithThreads = [];
576
- for (const tid of threadIds) {
577
- const threadMessagesKey = getThreadMessagesKey(tid);
578
- const msgIds = await this.client.zRange(threadMessagesKey, 0, -1);
579
- for (const mid of msgIds) allMessageIdsWithThreads.push({
577
+ threadIds.forEach((tid, i) => {
578
+ for (const mid of perThreadIds[i]) allMessageIdsWithThreads.push({
580
579
  threadId: tid,
581
580
  messageId: mid
582
581
  });
583
- }
582
+ });
584
583
  if (allMessageIdsWithThreads.length === 0) return {
585
584
  messages: [],
586
585
  total: 0,