feat(xo-server/collection/redis#_get): return undefined if missing
Related to #7281
This commit is contained in:
parent
0f00c7e393
commit
9be3c40ead
@ -192,12 +192,21 @@ export default class Redis extends Collection {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the record in the database
|
||||
*
|
||||
* Returns undefined if not present.
|
||||
*/
|
||||
async #get(key) {
|
||||
const { redis } = this
|
||||
|
||||
let model
|
||||
try {
|
||||
model = await redis.get(key).then(JSON.parse)
|
||||
const json = await redis.get(key)
|
||||
|
||||
if (json !== null) {
|
||||
model = JSON.parse(json)
|
||||
}
|
||||
} catch (error) {
|
||||
if (!error.message.startsWith('WRONGTYPE')) {
|
||||
throw error
|
||||
|
Loading…
Reference in New Issue
Block a user