@platformatic/next 2.21.0-alpha.2 → 2.21.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/lib/caching/valkey.js +12 -6
- package/package.json +6 -6
- package/schema.json +1 -1
package/lib/caching/valkey.js
CHANGED
|
@@ -38,9 +38,11 @@ export function getConnection (url) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export class CacheHandler {
|
|
41
|
+
#standalone
|
|
41
42
|
#config
|
|
42
43
|
#logger
|
|
43
44
|
#store
|
|
45
|
+
#prefix
|
|
44
46
|
#subprefix
|
|
45
47
|
#meta
|
|
46
48
|
#maxTTL
|
|
@@ -48,23 +50,27 @@ export class CacheHandler {
|
|
|
48
50
|
constructor (options) {
|
|
49
51
|
options ??= {}
|
|
50
52
|
|
|
53
|
+
this.#standalone = options.standalone
|
|
51
54
|
this.#config = options.config
|
|
52
55
|
this.#logger = options.logger
|
|
53
56
|
this.#store = options.store
|
|
54
57
|
this.#maxTTL = options.maxTTL
|
|
58
|
+
this.#prefix = options.prefix
|
|
55
59
|
this.#subprefix = options.subprefix
|
|
56
60
|
this.#meta = options.meta
|
|
57
61
|
|
|
58
|
-
if (globalThis.platformatic) {
|
|
62
|
+
if (!this.#standalone && globalThis.platformatic) {
|
|
59
63
|
this.#config ??= globalThis.platformatic.config.cache
|
|
60
64
|
this.#logger ??= this.#createPlatformaticLogger()
|
|
61
65
|
this.#store ??= getConnection(this.#config.url)
|
|
62
66
|
this.#maxTTL ??= this.#config.maxTTL
|
|
67
|
+
this.#prefix ??= this.#config.prefix
|
|
63
68
|
this.#subprefix ??= this.#getPlatformaticSubprefix()
|
|
64
69
|
this.#meta ??= this.#getPlatformaticMeta()
|
|
65
70
|
} else {
|
|
66
71
|
this.#config ??= {}
|
|
67
72
|
this.#maxTTL ??= 86_400
|
|
73
|
+
this.#prefix ??= ''
|
|
68
74
|
this.#subprefix ??= ''
|
|
69
75
|
this.#meta ??= {}
|
|
70
76
|
}
|
|
@@ -85,7 +91,7 @@ export class CacheHandler {
|
|
|
85
91
|
async get (cacheKey, _, isRedisKey) {
|
|
86
92
|
this.#logger.trace({ key: cacheKey }, 'get')
|
|
87
93
|
|
|
88
|
-
const key = isRedisKey ? cacheKey : this.#keyFor(cacheKey, sections.values)
|
|
94
|
+
const key = this.#standalone || isRedisKey ? cacheKey : this.#keyFor(cacheKey, sections.values)
|
|
89
95
|
|
|
90
96
|
let rawValue
|
|
91
97
|
try {
|
|
@@ -129,7 +135,7 @@ export class CacheHandler {
|
|
|
129
135
|
async set (cacheKey, value, { tags, revalidate }, isRedisKey) {
|
|
130
136
|
this.#logger.trace({ key: cacheKey, value, tags, revalidate }, 'set')
|
|
131
137
|
|
|
132
|
-
const key = isRedisKey ? cacheKey : this.#keyFor(cacheKey, sections.values)
|
|
138
|
+
const key = this.#standalone || isRedisKey ? cacheKey : this.#keyFor(cacheKey, sections.values)
|
|
133
139
|
|
|
134
140
|
try {
|
|
135
141
|
// Compute the parameters to save
|
|
@@ -172,7 +178,7 @@ export class CacheHandler {
|
|
|
172
178
|
async remove (cacheKey, isRedisKey) {
|
|
173
179
|
this.#logger.trace({ key: cacheKey }, 'remove')
|
|
174
180
|
|
|
175
|
-
const key = isRedisKey ? cacheKey : this.#keyFor(cacheKey, sections.values)
|
|
181
|
+
const key = this.#standalone || isRedisKey ? cacheKey : this.#keyFor(cacheKey, sections.values)
|
|
176
182
|
|
|
177
183
|
let rawValue
|
|
178
184
|
try {
|
|
@@ -207,7 +213,7 @@ export class CacheHandler {
|
|
|
207
213
|
if (Array.isArray(value.tags)) {
|
|
208
214
|
for (const tag of value.tags) {
|
|
209
215
|
const tagsKey = this.#keyFor(tag, sections.tags)
|
|
210
|
-
this.#store.srem(tagsKey, key
|
|
216
|
+
promises.push(this.#store.srem(tagsKey, key))
|
|
211
217
|
}
|
|
212
218
|
}
|
|
213
219
|
|
|
@@ -309,7 +315,7 @@ export class CacheHandler {
|
|
|
309
315
|
}
|
|
310
316
|
|
|
311
317
|
#keyFor (key, section) {
|
|
312
|
-
return keyFor(this.#
|
|
318
|
+
return keyFor(this.#prefix, this.#subprefix, section, key)
|
|
313
319
|
}
|
|
314
320
|
|
|
315
321
|
#serialize (data) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/next",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"description": "Platformatic Next.js Stackable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"iovalkey": "^0.2.1",
|
|
24
24
|
"msgpackr": "^1.11.2",
|
|
25
25
|
"semver": "^7.6.3",
|
|
26
|
-
"@platformatic/
|
|
27
|
-
"@platformatic/utils": "2.21.
|
|
28
|
-
"@platformatic/
|
|
26
|
+
"@platformatic/config": "2.21.1",
|
|
27
|
+
"@platformatic/utils": "2.21.1",
|
|
28
|
+
"@platformatic/basic": "2.21.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@fastify/reply-from": "^11.0.0",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"react-dom": "^18.3.1",
|
|
42
42
|
"typescript": "^5.5.4",
|
|
43
43
|
"ws": "^8.18.0",
|
|
44
|
-
"@platformatic/composer": "2.21.
|
|
45
|
-
"@platformatic/service": "2.21.
|
|
44
|
+
"@platformatic/composer": "2.21.1",
|
|
45
|
+
"@platformatic/service": "2.21.1"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"test": "npm run lint && borp --concurrency=1 --no-timeout",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/next/2.21.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/next/2.21.1.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Next.js Stackable",
|
|
5
5
|
"type": "object",
|