Created
January 5, 2018 17:40
-
-
Save hmpmarketing/e85b85266d43d20f83b3834ff1d64a02 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
const Memcached = require('memcached'); | |
const memcached = new Memcached('server.com:11211'); | |
memcached.on('issue', details => console.log('issue: ', details)) | |
memcached.on('failure', details => console.log('failure: ', details)) | |
memcached.on('reconnecting', details => console.log('reconnecting: ', details)) | |
memcached.on('reconnect', details => console.log('reconnect: ', details)) | |
memcached.on('remove', details => console.log('remove: ', details)) | |
const Cache = {} | |
Cache.add = function (key, value, lifetime) { | |
memcached.set(key, value, lifetime, function (err){ | |
if (err) console.warn(err) | |
}); | |
}; | |
Cache.get = function (key) { | |
memcached.get(key, function (err, data) { | |
if (err) console.warn(err) | |
console.log(data); | |
}); | |
}; | |
module.exports = Cache; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment