-
-
Save jkantr/f05bd08f8cc00b0ad4867d5bae5916d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cache.remember = function (key, lifetime, callback) { | |
return Promise.try(() => { | |
return memcached.getAsync(key); | |
}).then((value) => { | |
if (value !== undefined) { | |
return value; | |
} else { | |
return Promise.try(() => { | |
return callback() | |
}).then((value) => { | |
return memcached.setAsync(key, value, lifetime); | |
}).then(() => { | |
return value; | |
}) | |
} | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment