@platformatic/next 3.34.1-alpha.3 → 3.35.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.
@@ -169,17 +169,45 @@ export class CacheHandler {
169
169
  }
170
170
  }
171
171
 
172
- async refreshTags () {
173
- // this.#logger.trace('refreshTags - Not implemented')
174
- }
172
+ // This function is not necessary as we don't have a local state to synchronize.
173
+ async refreshTags () {}
175
174
 
176
175
  getExpiration (_tags) {
177
- // this.#logger.trace({ tags: _tags }, 'getExpiration - Not implemented')
176
+ // Delegates the check to get method, only when appropriate.
178
177
  return Number.POSITIVE_INFINITY
179
178
  }
180
179
 
181
- updateTags (_tags) {
182
- // this.#logger.trace({ tags: _tags }, 'updateTags - Not implemented')
180
+ async updateTags (tags) {
181
+ if (typeof tags === 'string') {
182
+ tags = [tags]
183
+ }
184
+
185
+ try {
186
+ const toDelete = new Set()
187
+
188
+ for (const tag of tags) {
189
+ const tagsKey = this.#keyFor(tag, sections.tags)
190
+
191
+ // For each key in the tag set, expire the key
192
+ for await (const keys of this.#store.sscanStream(tagsKey)) {
193
+ for (const key of keys) {
194
+ toDelete.add(key)
195
+
196
+ // Batch full, execute it
197
+ if (toDelete.length >= MAX_BATCH_SIZE) {
198
+ await this.#store.del(...toDelete)
199
+ toDelete.clear()
200
+ }
201
+ }
202
+ }
203
+
204
+ await this.#store.del(...toDelete)
205
+ await this.#store.del(tagsKey)
206
+ }
207
+ } catch (e) {
208
+ this.#logger.error({ err: ensureLoggableError(e) }, 'Cannot expire cache tags in Valkey')
209
+ throw new Error('Cannot expire cache tags in Valkey', { cause: e })
210
+ }
183
211
  }
184
212
 
185
213
  async #refreshKey (key, value) {
@@ -226,7 +226,7 @@ export class CacheHandler {
226
226
  }
227
227
 
228
228
  try {
229
- let promises = []
229
+ const toDelete = new Set()
230
230
 
231
231
  for (const tag of tags) {
232
232
  const tagsKey = this.#keyFor(tag, sections.tags)
@@ -234,20 +234,18 @@ export class CacheHandler {
234
234
  // For each key in the tag set, expire the key
235
235
  for await (const keys of this.#store.sscanStream(tagsKey)) {
236
236
  for (const key of keys) {
237
- promises.push(this.#store.del(key))
237
+ toDelete.add(key)
238
238
 
239
239
  // Batch full, execute it
240
- if (promises.length >= MAX_BATCH_SIZE) {
241
- await Promise.all(promises)
242
- promises = []
240
+ if (toDelete.size >= MAX_BATCH_SIZE) {
241
+ await this.#store.del(...toDelete)
242
+ toDelete.clear()
243
243
  }
244
244
  }
245
245
  }
246
246
 
247
- // Delete the set, this will also take care of executing pending operation for a non full batch
248
- promises.push(this.#store.del(tagsKey))
249
- await Promise.all(promises)
250
- promises = []
247
+ await this.#store.del(...toDelete)
248
+ await this.#store.del(tagsKey)
251
249
  }
252
250
  } catch (e) {
253
251
  this.#logger.error({ err: ensureLoggableError(e) }, 'Cannot expire cache tags in Valkey')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/next",
3
- "version": "3.34.1-alpha.3",
3
+ "version": "3.35.0",
4
4
  "description": "Platformatic Next.js Capability",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,8 +23,8 @@
23
23
  "iovalkey": "^0.3.0",
24
24
  "msgpackr": "^1.11.2",
25
25
  "semver": "^7.6.3",
26
- "@platformatic/basic": "3.34.1-alpha.3",
27
- "@platformatic/foundation": "3.34.1-alpha.3"
26
+ "@platformatic/basic": "3.35.0",
27
+ "@platformatic/foundation": "3.35.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@fastify/reply-from": "^12.0.0",
@@ -40,8 +40,8 @@
40
40
  "next": "^16.0.0",
41
41
  "typescript": "^5.5.4",
42
42
  "ws": "^8.18.0",
43
- "@platformatic/gateway": "3.34.1-alpha.3",
44
- "@platformatic/service": "3.34.1-alpha.3"
43
+ "@platformatic/gateway": "3.35.0",
44
+ "@platformatic/service": "3.35.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/next/3.34.1-alpha.3.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/next/3.35.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Next.js Config",
5
5
  "type": "object",