@knaus94/prisma-extension-cache-manager 1.5.51 → 1.5.53
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 +6 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57,7 +57,7 @@ function createKey(key, namespace) {
|
|
|
57
57
|
return namespace ? `${namespace}:${key}` : key;
|
|
58
58
|
}
|
|
59
59
|
function serialize(data) {
|
|
60
|
-
return mp.encode({ data });
|
|
60
|
+
return mp.encode({ data: data });
|
|
61
61
|
}
|
|
62
62
|
function deserialize(buffer) {
|
|
63
63
|
return mp.decode(buffer).data;
|
|
@@ -198,7 +198,7 @@ exports.default = ({ cache, defaultTTL, debug }) => {
|
|
|
198
198
|
try {
|
|
199
199
|
await cache.set(cacheKey, serialize(result), ttl);
|
|
200
200
|
if (debug) {
|
|
201
|
-
console.log("Data cached with key (function):", cacheKey, "encoded:",
|
|
201
|
+
console.log("Data cached with key (function):", cacheKey, "encoded:", serialize(result), "decoded:", result);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
catch (e) {
|
|
@@ -221,12 +221,11 @@ exports.default = ({ cache, defaultTTL, debug }) => {
|
|
|
221
221
|
// Используем getBuffer, т.к. сохраняем бинарные данные
|
|
222
222
|
const cached = await cache.store.client.getBuffer(cacheKey);
|
|
223
223
|
if (cached) {
|
|
224
|
-
const data = deserialize(cached);
|
|
225
224
|
if (debug) {
|
|
226
|
-
console.log("Cache hit for key:", cacheKey, "data", cached, "decoded",
|
|
225
|
+
console.log("Cache hit for key:", cacheKey, "data", cached, "decoded", mp.decode(cached));
|
|
227
226
|
}
|
|
228
227
|
// Десериализуем через msgpack5
|
|
229
|
-
return
|
|
228
|
+
return deserialize(cached);
|
|
230
229
|
}
|
|
231
230
|
else {
|
|
232
231
|
if (debug) {
|
|
@@ -248,10 +247,9 @@ exports.default = ({ cache, defaultTTL, debug }) => {
|
|
|
248
247
|
}
|
|
249
248
|
// 6. Сохраняем результат запроса в кеш
|
|
250
249
|
try {
|
|
251
|
-
|
|
252
|
-
await cache.set(cacheKey, data, ttl);
|
|
250
|
+
await cache.set(cacheKey, serialize(result), ttl);
|
|
253
251
|
if (debug) {
|
|
254
|
-
console.log("Data cached with key:", cacheKey, "encoded:",
|
|
252
|
+
console.log("Data cached with key:", cacheKey, "encoded:", serialize(result), "decoded:", result);
|
|
255
253
|
}
|
|
256
254
|
}
|
|
257
255
|
catch (e) {
|