@mastra/redis 1.1.0 → 1.1.1

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
@@ -146,13 +146,16 @@ var StoreMemoryRedis = class extends MemoryStorage {
146
146
  await this.db.scanAndDelete("msg-idx:*");
147
147
  await this.db.scanAndDelete("thread:*:messages");
148
148
  }
149
- async getThreadById({ threadId }) {
149
+ async getThreadById({
150
+ threadId,
151
+ resourceId
152
+ }) {
150
153
  try {
151
154
  const thread = await this.db.get({
152
155
  tableName: TABLE_THREADS,
153
156
  keys: { id: threadId }
154
157
  });
155
- if (!thread) {
158
+ if (!thread || resourceId !== void 0 && thread.resourceId !== resourceId) {
156
159
  return null;
157
160
  }
158
161
  return {
@@ -1834,11 +1837,13 @@ var RedisServerCache = class extends MastraServerCache {
1834
1837
  }
1835
1838
  return this.deserialize(value);
1836
1839
  }
1837
- async set(key, value) {
1840
+ async set(key, value, ttlMs) {
1838
1841
  const fullKey = this.getKey(key);
1839
1842
  const serialized = this.serialize(value);
1840
- if (this.ttlSeconds > 0) {
1841
- await this.setWithExpiry(this.client, fullKey, serialized, this.ttlSeconds);
1843
+ const overrideSeconds = ttlMs !== void 0 ? Math.max(1, Math.ceil(ttlMs / 1e3)) : void 0;
1844
+ const effectiveSeconds = overrideSeconds ?? this.ttlSeconds;
1845
+ if (effectiveSeconds > 0) {
1846
+ await this.setWithExpiry(this.client, fullKey, serialized, effectiveSeconds);
1842
1847
  } else {
1843
1848
  await this.client.set(fullKey, serialized);
1844
1849
  }