@vercel/functions 2.2.0 → 2.2.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/CHANGELOG.md +6 -0
- package/cache/index.js +10 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/cache/index.js
CHANGED
|
@@ -33,15 +33,15 @@ const defaultKeyHashFunction = (key) => {
|
|
|
33
33
|
const defaultNamespaceSeparator = "$";
|
|
34
34
|
let inMemoryCacheInstance = null;
|
|
35
35
|
const getCache = (cacheOptions) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const resolveCache = () => {
|
|
37
|
+
const ctxCache = (0, import_get_context.getContext)().cache;
|
|
38
|
+
if (ctxCache)
|
|
39
|
+
return ctxCache;
|
|
40
40
|
if (!inMemoryCacheInstance) {
|
|
41
41
|
inMemoryCacheInstance = new import_in_memory_cache.InMemoryCache();
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
}
|
|
43
|
+
return inMemoryCacheInstance;
|
|
44
|
+
};
|
|
45
45
|
const hashFunction = cacheOptions?.keyHashFunction || defaultKeyHashFunction;
|
|
46
46
|
const makeKey = (key) => {
|
|
47
47
|
let prefix = "";
|
|
@@ -53,16 +53,16 @@ const getCache = (cacheOptions) => {
|
|
|
53
53
|
};
|
|
54
54
|
return {
|
|
55
55
|
get: (key, options) => {
|
|
56
|
-
return
|
|
56
|
+
return resolveCache().get(makeKey(key), options);
|
|
57
57
|
},
|
|
58
58
|
set: (key, value, options) => {
|
|
59
|
-
return
|
|
59
|
+
return resolveCache().set(makeKey(key), value, options);
|
|
60
60
|
},
|
|
61
61
|
delete: (key) => {
|
|
62
|
-
return
|
|
62
|
+
return resolveCache().delete(makeKey(key));
|
|
63
63
|
},
|
|
64
64
|
expireTag: (tag) => {
|
|
65
|
-
return
|
|
65
|
+
return resolveCache().expireTag(tag);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
};
|