fix(core): throw URL cache key (#10497)

This commit is contained in:
Tony
2022-08-16 01:38:05 -12:00
committed by GitHub
parent aef0b0a9b0
commit 4877301f23
3 changed files with 31 additions and 0 deletions

View File

@@ -56,6 +56,9 @@ module.exports = function (app) {
app.context.cache = {
...cacheModule,
tryGet: async (key, getValueFunc, maxAge = config.cache.contentExpire, refresh = true) => {
if (typeof key !== 'string') {
throw Error('Cache key must be a string');
}
let v = await get(key, refresh);
if (!v) {
v = await getValueFunc();