npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

queuep-redis

v1.2.1

Published

Redis based storage strategy for queuep

Downloads

20

Readme

queuep-redis

This is a redis based storage strategy for queuep. Thus to make use of this library you should be using queuep already.

QueueP is a congestion control framework designed for NodeJs applications. Go have a look at https://www.npmjs.com/package/queuep

Installation

npm install --save queuep-redis

Usage

Note: We assume that you already have a redis-server up and running.

First import queuep and queuep-redis

import qp from 'queuep';
import RedisStore from 'queuep-redis';

Then you can set the storage to queuep-redis when initializing queuep by providing the store as the first argument to init method. Note that we are using uppercase for the first letter since the store imported from queuep-redis is a class definition. It is not compulsory, but makes more sense internally.

qp.init(RedisStore);

This class is initiated by queuep. If you want to customize the redis connection, then you can pass an optional options object to the init method. The following example shows how you can authenticate the connection, change the database to the index 1 and change the unix socket path.

qp.init(RedisStore, {
    password: "secret_password",
    path: "unix socket path",
    db: 1
});

You can also set the storage using the useStore method.

qp.useStore(RedisStore, options);

We recommend to set the storage before initializing any queuep queues. It would not break the code if not. But the code will look cleaner with the recommended approach.

You can also set redis storage to a particular queue while initializing a queue. To do that,

let myQueue = qp.initQueue("my_queue", {
    consumer: this.myConsumer,
    storeSpec: {
        store: RedisStore,
        options: {
            /* 
             * Redis connection options can be specified here
             * For instance, if you have enabled authentication in the redis server, you can pass the password here
             * Or else, if you want to use a different database, you can pass the db index here
             * For all available options, please refer the node_redis docs at https://www.npmjs.com/package/redis#rediscreateclient
            */
        }
    }
});

Or even after initializing using the setStore method. But we would not recommend this unless there is no other choice.

To do that,

let queue = qp.getQueueInstance("my_queue");
queue.setStore(RedisStore, options);

or

qp.setStore("my_queue", RedisStore, options);