1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-01 03:21:21 +00:00

Merge pull request #347 from seejohnrun/fix-memcached

Fix memcached client fetch for key not found
This commit is contained in:
John Crepezzi 2020-10-06 01:39:52 -04:00 committed by GitHub
commit 89d912c6ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,7 @@ class MemcachedDocumentStore {
// Save file in a key // Save file in a key
set(key, data, callback, skipExpire) { set(key, data, callback, skipExpire) {
this.client.set(key, data, skipExpire ? 0 : this.expire, (error) => { this.client.set(key, data, skipExpire ? 0 : this.expire || 0, (error) => {
callback(!error); callback(!error);
}); });
} }
@ -34,10 +34,12 @@ class MemcachedDocumentStore {
// Get a file from a key // Get a file from a key
get(key, callback, skipExpire) { get(key, callback, skipExpire) {
this.client.get(key, (error, data) => { this.client.get(key, (error, data) => {
callback(error ? false : data); const value = error ? false : data;
callback(value);
// Update the key so that the expiration is pushed forward // Update the key so that the expiration is pushed forward
if (!skipExpire) { if (value && !skipExpire) {
this.set(key, data, (updateSucceeded) => { this.set(key, data, (updateSucceeded) => {
if (!updateSucceeded) { if (!updateSucceeded) {
winston.error('failed to update expiration on GET', {key}); winston.error('failed to update expiration on GET', {key});