Jack M.
Jack M.

Reputation: 3804

Memcached connecting but not working using NodeJs

I have just installed memcached on my vmware debian server and the nodejs script looks like this:

var Memcached   = require('memcached');
var memcached = new Memcached('127.0.0.1:11211');

memcached.set('foo', 'dass');
var data = memcached.get('foo');

console.log(data);
console.log(memcached.stats);

For the first console.log I get this: undefined

For the second console.log I get this: [Function: bowlofcurry]

Not sure what am doing wrong here :( anyone?

The module: https://www.npmjs.org/package/memcached

Upvotes: 0

Views: 1492

Answers (1)

sNICkerssss
sNICkerssss

Reputation: 6430

Data will come in callback:

memcached.get('foo', function (err, data)
{            
    console.log(data);
});

Full documentation here.

Upvotes: 1

Related Questions