@knaus94/prisma-extension-cache-manager 1.5.0 → 1.5.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/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { ModelExtension, PrismaRedisCacheConfig } from "./types";
4
4
  * @param config - Конфигурация для кеша Redis и TTL по умолчанию.
5
5
  * @returns Prisma расширение.
6
6
  */
7
- declare const _default: ({ cache, defaultTTL }: PrismaRedisCacheConfig) => (client: any) => import("@prisma/client/extension").PrismaClientExtends<import("@prisma/client/runtime/library").InternalArgs<{}, {
7
+ declare const _default: ({ cache, defaultTTL, debug }: PrismaRedisCacheConfig) => (client: any) => import("@prisma/client/extension").PrismaClientExtends<import("@prisma/client/runtime/library").InternalArgs<{}, {
8
8
  $allModels: ModelExtension;
9
9
  }, {}, {
10
10
  $cache: import("cache-manager-ioredis-yet").RedisCache;
package/dist/index.js CHANGED
@@ -119,7 +119,7 @@ function shouldUseUncache(uncacheOption) {
119
119
  * @param config - Конфигурация для кеша Redis и TTL по умолчанию.
120
120
  * @returns Prisma расширение.
121
121
  */
122
- exports.default = ({ cache, defaultTTL }) => {
122
+ exports.default = ({ cache, defaultTTL, debug }) => {
123
123
  return extension_1.Prisma.defineExtension({
124
124
  name: "prisma-extension-cache-manager",
125
125
  client: {
@@ -192,7 +192,11 @@ exports.default = ({ cache, defaultTTL }) => {
192
192
  return deserializeData(msgpack5_1.default.decode(cached));
193
193
  }
194
194
  }
195
- catch { }
195
+ catch (e) {
196
+ if (debug) {
197
+ console.error("Failed to get cache", e);
198
+ }
199
+ }
196
200
  }
197
201
  // Выполняем запрос к базе данных
198
202
  const result = await query(queryArgs);
@@ -204,7 +208,11 @@ exports.default = ({ cache, defaultTTL }) => {
204
208
  try {
205
209
  await cache.set(cacheKey, msgpack5_1.default.encode(serializeData(result)), ttl);
206
210
  }
207
- catch { }
211
+ catch (e) {
212
+ if (debug) {
213
+ console.error("Failed to set cache", e);
214
+ }
215
+ }
208
216
  return result;
209
217
  },
210
218
  },
package/dist/types.d.ts CHANGED
@@ -36,5 +36,6 @@ export interface PrismaCacheArgs<T, A, O extends RequiredArgsOperation | Optiona
36
36
  export interface PrismaRedisCacheConfig {
37
37
  cache: RedisCache;
38
38
  defaultTTL?: number;
39
+ debug?: boolean;
39
40
  }
40
41
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knaus94/prisma-extension-cache-manager",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/knaus94/prisma-extension-cache-manager.git"