Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return redisClient.get(userId).then(function(cachedUser) {
if (cachedUser) {
// 反序列化为 AV.Object
return AV.parseJSON(JSON.parse(cachedUser))
} else {
new AV.Query(AV.User).get(userId).then(function(user) {
if (user) {
// 将序列化后的 JSON 字符串存储到 LeanCache
redisClient.set(redisUserKey(userId), JSON.stringify(user.toFullJSON())).catch(console.error)
}
return user
})
}
})
}
return categories.map( category => {
return AV.parseJSON(JSON.parse(category))
})
})