strapi-cache 1.11.0 → 1.11.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/server/index.js
CHANGED
|
@@ -943,7 +943,7 @@ class RedisCacheProvider {
|
|
|
943
943
|
async del(key) {
|
|
944
944
|
if (!this.ready) return null;
|
|
945
945
|
try {
|
|
946
|
-
const relativeKey = key.slice(this.keyPrefix.length);
|
|
946
|
+
const relativeKey = this.keyPrefix && key.startsWith(this.keyPrefix) ? key.slice(this.keyPrefix.length) : key;
|
|
947
947
|
loggy.info(`Redis PURGING KEY: ${relativeKey}`);
|
|
948
948
|
await this.client.del(relativeKey);
|
|
949
949
|
return true;
|
|
@@ -982,18 +982,32 @@ class RedisCacheProvider {
|
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
984
|
async deleteBatch(client, batch, regExps) {
|
|
985
|
-
const toDelete = batch.filter((key) =>
|
|
985
|
+
const toDelete = batch.filter((key) => {
|
|
986
|
+
if (!this.hasConfiguredPrefix(key)) {
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
const relativeKey = this.toRelativeKey(key);
|
|
990
|
+
return regExps.some((re) => re.test(key) || re.test(relativeKey));
|
|
991
|
+
});
|
|
986
992
|
if (toDelete.length === 0) return;
|
|
987
993
|
const pipeline = client.pipeline();
|
|
988
994
|
for (const key of toDelete) {
|
|
989
|
-
|
|
990
|
-
pipeline.del(relativeKey);
|
|
995
|
+
pipeline.del(this.toRelativeKey(key));
|
|
991
996
|
}
|
|
992
997
|
await pipeline.exec();
|
|
993
998
|
}
|
|
999
|
+
hasConfiguredPrefix(key) {
|
|
1000
|
+
return !this.keyPrefix || key.startsWith(this.keyPrefix);
|
|
1001
|
+
}
|
|
1002
|
+
toRelativeKey(key) {
|
|
1003
|
+
return this.keyPrefix && key.startsWith(this.keyPrefix) ? key.slice(this.keyPrefix.length) : key;
|
|
1004
|
+
}
|
|
994
1005
|
scanAndDelete(client, regExps) {
|
|
995
1006
|
return new Promise((resolve, reject) => {
|
|
996
|
-
const stream = client.scanStream({
|
|
1007
|
+
const stream = client.scanStream({
|
|
1008
|
+
match: `${this.keyPrefix}*`,
|
|
1009
|
+
count: this.redisScanDeleteCount
|
|
1010
|
+
});
|
|
997
1011
|
stream.on("data", (batch) => {
|
|
998
1012
|
stream.pause();
|
|
999
1013
|
this.deleteBatch(client, batch, regExps).then(() => stream.resume()).catch(reject);
|
package/dist/server/index.mjs
CHANGED
|
@@ -939,7 +939,7 @@ class RedisCacheProvider {
|
|
|
939
939
|
async del(key) {
|
|
940
940
|
if (!this.ready) return null;
|
|
941
941
|
try {
|
|
942
|
-
const relativeKey = key.slice(this.keyPrefix.length);
|
|
942
|
+
const relativeKey = this.keyPrefix && key.startsWith(this.keyPrefix) ? key.slice(this.keyPrefix.length) : key;
|
|
943
943
|
loggy.info(`Redis PURGING KEY: ${relativeKey}`);
|
|
944
944
|
await this.client.del(relativeKey);
|
|
945
945
|
return true;
|
|
@@ -978,18 +978,32 @@ class RedisCacheProvider {
|
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
980
|
async deleteBatch(client, batch, regExps) {
|
|
981
|
-
const toDelete = batch.filter((key) =>
|
|
981
|
+
const toDelete = batch.filter((key) => {
|
|
982
|
+
if (!this.hasConfiguredPrefix(key)) {
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
const relativeKey = this.toRelativeKey(key);
|
|
986
|
+
return regExps.some((re) => re.test(key) || re.test(relativeKey));
|
|
987
|
+
});
|
|
982
988
|
if (toDelete.length === 0) return;
|
|
983
989
|
const pipeline = client.pipeline();
|
|
984
990
|
for (const key of toDelete) {
|
|
985
|
-
|
|
986
|
-
pipeline.del(relativeKey);
|
|
991
|
+
pipeline.del(this.toRelativeKey(key));
|
|
987
992
|
}
|
|
988
993
|
await pipeline.exec();
|
|
989
994
|
}
|
|
995
|
+
hasConfiguredPrefix(key) {
|
|
996
|
+
return !this.keyPrefix || key.startsWith(this.keyPrefix);
|
|
997
|
+
}
|
|
998
|
+
toRelativeKey(key) {
|
|
999
|
+
return this.keyPrefix && key.startsWith(this.keyPrefix) ? key.slice(this.keyPrefix.length) : key;
|
|
1000
|
+
}
|
|
990
1001
|
scanAndDelete(client, regExps) {
|
|
991
1002
|
return new Promise((resolve, reject) => {
|
|
992
|
-
const stream = client.scanStream({
|
|
1003
|
+
const stream = client.scanStream({
|
|
1004
|
+
match: `${this.keyPrefix}*`,
|
|
1005
|
+
count: this.redisScanDeleteCount
|
|
1006
|
+
});
|
|
993
1007
|
stream.on("data", (batch) => {
|
|
994
1008
|
stream.pause();
|
|
995
1009
|
this.deleteBatch(client, batch, regExps).then(() => stream.resume()).catch(reject);
|
|
@@ -16,6 +16,8 @@ export declare class RedisCacheProvider implements CacheProvider {
|
|
|
16
16
|
keys(): Promise<string[] | null>;
|
|
17
17
|
reset(): Promise<any | null>;
|
|
18
18
|
private deleteBatch;
|
|
19
|
+
private hasConfiguredPrefix;
|
|
20
|
+
private toRelativeKey;
|
|
19
21
|
private scanAndDelete;
|
|
20
22
|
/**
|
|
21
23
|
* ScanStream keys and batch delete for Redis,
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.11.
|
|
2
|
+
"version": "1.11.1",
|
|
3
3
|
"keywords": [
|
|
4
4
|
"strapi cache",
|
|
5
5
|
"strapi rest cache",
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"vitest": "^3.1.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@strapi/sdk-plugin": "^5.3.2",
|
|
73
72
|
"@strapi/strapi": "^5.0.0",
|
|
74
73
|
"react": "^18.3.1",
|
|
75
74
|
"react-dom": "^18.3.1",
|
|
@@ -81,6 +80,18 @@
|
|
|
81
80
|
"@rollup/rollup-linux-x64-gnu": "*",
|
|
82
81
|
"@swc/core-linux-x64-gnu": "*"
|
|
83
82
|
},
|
|
83
|
+
"overrides": {
|
|
84
|
+
"@ai-sdk/gateway": "3.0.131",
|
|
85
|
+
"@ai-sdk/provider-utils": "4.0.29",
|
|
86
|
+
"@ai-sdk/react": "3.0.207",
|
|
87
|
+
"@vitejs/plugin-react-swc": "3.11.0",
|
|
88
|
+
"ai": "6.0.205",
|
|
89
|
+
"ajv": "8.20.0",
|
|
90
|
+
"esbuild": "0.28.1",
|
|
91
|
+
"esbuild-loader": "4.5.0",
|
|
92
|
+
"lodash": "4.18.1",
|
|
93
|
+
"vite": "6.4.3"
|
|
94
|
+
},
|
|
84
95
|
"strapi": {
|
|
85
96
|
"kind": "plugin",
|
|
86
97
|
"name": "strapi-cache",
|