Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including memqueue with all npm packages installed. Try it out:

var memqueue = require("memqueue")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

memqueue v1.2.0

This library is an implementation of a queue with memcached

MemQueue

Build Status Code Climate Test Coverage Issue Count Dependencies Checker Join the chat at https://gitter.im/nachonerd/memqueue

NPM

Description

This NodeJs library is an implementation of queue with memcached.

Installation

npm install memqueue

Usage

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();
    });
});

Methods

Kind: global class
Api: public

new MemQueue(key, locations, options)

Constructor

ParamTypeDescription
keyMixedKey String or Number
locationsMixedArray, string or object with servers
optionsObjectOptions

push(value, lifetime, callback) ⇒ void

Push

Stores a new value in Memqueue. Emits: push
Api: public

ParamTypeDescription
valueMixedEither a buffer, JSON, number or string that you want to store.
lifetimeNumberhow long the data needs to be stored measured in seconds
callbackfunctionthe callback

pop(callback) ⇒ void

Pop

Retrieve Last value from memqueue. Emits: pop, empty Api: public

ParamTypeDescription
callbackfunctionthe callback

end() ⇒ void

End

Finish memcached connection.

Api: public

For more information see Documentation

License

The driver is released under the GPL-3.0 license. See the LICENSE for more information.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free