-
-
Save jkantr/ae356a2828f9182d1e0902af00e52707 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 Promise = require('bluebird'); | |
const memcache = require('./memcached.js'); | |
const lifetime = 100 // i don't actually know what this is.. fill in the correct thing :p | |
Promise.try(() => { | |
return memcache.add('foo', 'bar', lifetime); | |
}).then(() => { | |
return memcache.get('foo'); | |
}).then((foo) => { | |
console.log(foo) // should be 'bar' i imagine... | |
}) |
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 Promise = require('bluebird'); | |
const Memcached = require('memcached'); | |
const memcached = new Memcached('memcacheserver:11211'); | |
Promise.promisifyAll(memcached); | |
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) { | |
return memcached.setAsync(key, value, lifetime); | |
}; | |
Cache.get = function (key) { | |
return memcached.getAsync(key) | |
}; | |
module.exports = Cache; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment