-
-
Save hmpmarketing/e2f0d9a31d997b89a52fca685f311780 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