@vercel/functions 2.2.0 → 2.2.2
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 +12 -0
- package/cache/index.js +13 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @vercel/functions
|
|
2
2
|
|
|
3
|
+
## 2.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add warning when calling getCache to indicate that in-memory cache is being used. ([#13455](https://github.com/vercel/vercel/pull/13455))
|
|
8
|
+
|
|
9
|
+
## 2.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Update runtime cache to always use the current cache instance to prevent holding a stale copy ([#13454](https://github.com/vercel/vercel/pull/13454))
|
|
14
|
+
|
|
3
15
|
## 2.2.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/cache/index.js
CHANGED
|
@@ -33,15 +33,18 @@ 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
|
+
console.warn(
|
|
43
|
+
"Runtime Cache unavailable in this environment. Falling back to in-memory cache."
|
|
44
|
+
);
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
}
|
|
46
|
+
return inMemoryCacheInstance;
|
|
47
|
+
};
|
|
45
48
|
const hashFunction = cacheOptions?.keyHashFunction || defaultKeyHashFunction;
|
|
46
49
|
const makeKey = (key) => {
|
|
47
50
|
let prefix = "";
|
|
@@ -53,16 +56,16 @@ const getCache = (cacheOptions) => {
|
|
|
53
56
|
};
|
|
54
57
|
return {
|
|
55
58
|
get: (key, options) => {
|
|
56
|
-
return
|
|
59
|
+
return resolveCache().get(makeKey(key), options);
|
|
57
60
|
},
|
|
58
61
|
set: (key, value, options) => {
|
|
59
|
-
return
|
|
62
|
+
return resolveCache().set(makeKey(key), value, options);
|
|
60
63
|
},
|
|
61
64
|
delete: (key) => {
|
|
62
|
-
return
|
|
65
|
+
return resolveCache().delete(makeKey(key));
|
|
63
66
|
},
|
|
64
67
|
expireTag: (tag) => {
|
|
65
|
-
return
|
|
68
|
+
return resolveCache().expireTag(tag);
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
};
|