@knaus94/prisma-extension-cache-manager 1.3.9 → 1.4.0
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 +1 -1
- package/dist/index.js +6 -4
- package/dist/types.d.ts +1 -0
- package/package.json +1 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModelExtension, PrismaRedisCacheConfig } from "./types";
|
|
2
|
-
declare const _default: ({ cache }: PrismaRedisCacheConfig) => (client: any) => import("@prisma/client/extension").PrismaClientExtends<import("@prisma/client/runtime/library").InternalArgs<{}, {
|
|
2
|
+
declare const _default: ({ cache, defaultTTL }: PrismaRedisCacheConfig) => (client: any) => import("@prisma/client/extension").PrismaClientExtends<import("@prisma/client/runtime/library").InternalArgs<{}, {
|
|
3
3
|
$allModels: ModelExtension;
|
|
4
4
|
}, {}, {
|
|
5
5
|
$cache: import("cache-manager").Cache;
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ function serializeData(data) {
|
|
|
18
18
|
function deserializeData(serializedData) {
|
|
19
19
|
return JSON.parse(serializedData).data;
|
|
20
20
|
}
|
|
21
|
-
exports.default = ({ cache }) => {
|
|
21
|
+
exports.default = ({ cache, defaultTTL }) => {
|
|
22
22
|
return extension_1.Prisma.defineExtension({
|
|
23
23
|
name: "prisma-extension-cache-manager",
|
|
24
24
|
client: {
|
|
@@ -93,7 +93,9 @@ exports.default = ({ cache }) => {
|
|
|
93
93
|
const result = await query(queryArgs);
|
|
94
94
|
if (useUncache)
|
|
95
95
|
processUncache(result);
|
|
96
|
-
const ttl = typeof cacheOption === "number"
|
|
96
|
+
const ttl = typeof cacheOption === "number"
|
|
97
|
+
? cacheOption
|
|
98
|
+
: defaultTTL ?? undefined;
|
|
97
99
|
await cache.set(cacheKey, serializeData(result), ttl);
|
|
98
100
|
return result;
|
|
99
101
|
}
|
|
@@ -102,7 +104,7 @@ exports.default = ({ cache }) => {
|
|
|
102
104
|
if (useUncache)
|
|
103
105
|
processUncache(result);
|
|
104
106
|
const customCacheKey = cacheOption.key(result);
|
|
105
|
-
await cache.set(customCacheKey, serializeData(result), cacheOption.ttl);
|
|
107
|
+
await cache.set(customCacheKey, serializeData(result), cacheOption.ttl ?? defaultTTL);
|
|
106
108
|
return result;
|
|
107
109
|
}
|
|
108
110
|
const customCacheKey = createKey(cacheOption.key, cacheOption.namespace) ||
|
|
@@ -119,7 +121,7 @@ exports.default = ({ cache }) => {
|
|
|
119
121
|
const result = await query(queryArgs);
|
|
120
122
|
if (useUncache)
|
|
121
123
|
processUncache(result);
|
|
122
|
-
await cache.set(customCacheKey, serializeData(result), cacheOption.ttl);
|
|
124
|
+
await cache.set(customCacheKey, serializeData(result), cacheOption.ttl ?? defaultTTL);
|
|
123
125
|
return result;
|
|
124
126
|
},
|
|
125
127
|
},
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knaus94/prisma-extension-cache-manager",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/knaus94/prisma-extension-cache-manager.git"
|
|
7
7
|
},
|
|
8
|
-
"homepage": "https://github.com/knaus94/prisma-extension-cache-manager",
|
|
9
|
-
"bugs": "https://github.com/knaus94/prisma-extension-cache-manager/issues",
|
|
10
8
|
"author": {
|
|
11
9
|
"name": "knaus94",
|
|
12
10
|
"url": "https://github.com/knaus94"
|