@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.
Files changed (2) hide show
  1. package/dist/index.js +6 -8
  2. 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:", mp.encode(result), "decoded:", result);
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", data);
225
+ console.log("Cache hit for key:", cacheKey, "data", cached, "decoded", mp.decode(cached));
227
226
  }
228
227
  // Десериализуем через msgpack5
229
- return data;
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
- const data = serialize(result);
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:", data, "decoded:", result);
252
+ console.log("Data cached with key:", cacheKey, "encoded:", serialize(result), "decoded:", result);
255
253
  }
256
254
  }
257
255
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knaus94/prisma-extension-cache-manager",
3
- "version": "1.5.51",
3
+ "version": "1.5.53",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/knaus94/prisma-extension-cache-manager.git"