Hi I'm new to Memcached elasticache with AWS. I found this plugin that gives me an array of hosts from a host configuration, but I'm not 100% certain what best practices dictates. My code looks similar to this...
var Ecad = require('ecad');
var endpoints = ['memcached.w7sebn.cfg.usw2.cache.amazonaws.com:11211'];
var client = new Ecad({endpoints: endpoints, timeout: 10000});
client.fetch(function(err,hosts){console.log(err);console.log(hosts);});
Where console.log(hosts) prints out an array of hosts I can probably use. So am I supposed to implement my own hashing algorithm to determine which memcached nodes I connect and use like ->
var Ecad = require('ecad');
var endpoints = ['memcached.w7sebn.cfg.usw2.cache.amazonaws.com:11211'];
var client = new Ecad({endpoints: endpoints, timeout: 10000});
client.fetch(function(err,hosts){
var connectTo = hosts[parseInt(Math.random() * hosts.length)];
var Memcached = require('memcached');
// We can throw in options as a second parameter
// For info please refer to:
//
// https://www.npmjs.com/package/memcached
var memcached = new Memcached(connectTo);
memcached.set("TestKey", "Memcache Works!", 100, function (err) {
memcached.get("TestKey", function (err, data) {
console.log(data);
});
});
});
Or is there more to it?