This NodeJs library is an implementation of queue with memcached.
npm install memqueue
var MemQueue = require('memqueue');
console.info("Creating Queue...");
try {
// create a new queue
var queue = new MemQueue("myqueue", 'localhost:11213');
} catch (e) {
console.error("Creation Fail: "+e.message);
}
var element = "element"+Math.floor((Math.random()*10000));
console.info("Pushing first element: "+element);
// push an element into the queue.
queue.push(element, 10, function (err) {
if (err) {
console.error("Push Fail: "+err);
}
console.info("Retrieveing last element");
// retrieve the previously pushed object .
queue.pop(function (err, data) {
if (err) {
console.error("Pop Fail: "+err);
}
console.info("The last element was: "+data);
// end memcached connection.
queue.end();
});
});
Kind: global class
Api: public
Constructor
Param | Type | Description |
---|---|---|
key | Mixed |
Key String or Number |
locations | Mixed |
Array, string or object with servers |
options | Object |
Options |
Push
Stores a new value in Memqueue.
Emits: push
Api: public
Param | Type | Description |
---|---|---|
value | Mixed |
Either a buffer, JSON, number or string that you want to store. |
lifetime | Number |
how long the data needs to be stored measured in seconds |
callback | function |
the callback |
Pop
Retrieve Last value from memqueue.
Emits: pop
, empty
Api: public
Param | Type | Description |
---|---|---|
callback | function |
the callback |
End
Finish memcached connection.
Api: public
For more information see Documentation
The driver is released under the GPL-3.0 license. See the LICENSE for more information.