@knaus94/prisma-extension-cache-manager 1.5.61 → 1.5.62
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 +12 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -196,7 +196,12 @@ exports.default = ({ cache, defaultTTL, debug }) => {
|
|
|
196
196
|
ttl = cacheOption.ttl ?? defaultTTL ?? 0;
|
|
197
197
|
// Сохраняем результат в кеш, используя msgpack5
|
|
198
198
|
try {
|
|
199
|
-
|
|
199
|
+
if (ttl > 0) {
|
|
200
|
+
await cache.store.client.set(cacheKey, serialize(result), "EX", ttl / 1000);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
await cache.store.client.set(cacheKey, serialize(result));
|
|
204
|
+
}
|
|
200
205
|
if (debug) {
|
|
201
206
|
console.log("Data cached with key (function):", cacheKey, "encoded:", serialize(result), "decoded:", result);
|
|
202
207
|
}
|
|
@@ -249,7 +254,12 @@ exports.default = ({ cache, defaultTTL, debug }) => {
|
|
|
249
254
|
// 6. Сохраняем результат запроса в кеш
|
|
250
255
|
try {
|
|
251
256
|
const data = serialize(result);
|
|
252
|
-
|
|
257
|
+
if (ttl > 0) {
|
|
258
|
+
await cache.store.client.set(cacheKey, data, "EX", ttl / 1000);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
await cache.store.client.set(cacheKey, data);
|
|
262
|
+
}
|
|
253
263
|
if (debug) {
|
|
254
264
|
console.log("Data cached with key:", cacheKey, "encoded:", data, "decoded:", result);
|
|
255
265
|
}
|