Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let response;
try {
response = await this.request(this._getCachePath(key), {
method: 'get',
encoding: null
});
} catch (e) {
if (e.name === 'HTTPError') {
// TODO: Log 500+ verbosely?
return null;
} else {
throw e;
}
}
return deserialize(response.body);
}
async get(key: string) {
try {
let data = await this.fs.readFile(this._getCachePath(key));
return deserialize(data);
} catch (err) {
if (err.code === 'ENOENT') {
return null;
} else {
throw err;
}
}
}
handleMessage(data: string) {
if (data === 'die') {
return this.stop();
}
this.onMessage(deserialize(Buffer.from(data, 'base64')));
}
async get(key: string) {
try {
let data = await this.fs.readFile(this._getCachePath(key));
return deserialize(data);
} catch (err) {
if (err.code === 'ENOENT') {
return null;
} else {
throw err;
}
}
}
this.child.on('message', (data: string) => {
this.onMessage(deserialize(Buffer.from(data, 'base64')));
});