Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deja-qu

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deja-qu

Emphemeral message queue for Node

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Déjà qu

npm version Build Status codecov codebeat badge Dependencies

Déjà qu is Redis-backed FIFO message queue for storing any kind of ephemeral data. It allows you to easily build ephemeral timelines/stories. Messages are automatically removed from the queue once they're expired, without the need for polling, cron jobs, or timers.

Installation

If using yarn:

yarn add deja-qu

or npm:

npm install deja-qu --save

Run Redis server:

redis-server

Check out Redis quickstart to install.

Usage

Step 1: Initialize and start Déjà qu

Require Déjà qu:

const DejaQu = require('deja-qu').DejaQu;

Initialize Déjà qu, connecting to a local Redis server running on the default port:

const dq = new DejaQu();

Optionally pass in a Redis configuration to connect to a remote server.

const dq = new DejaQu(REDIS_CLOUD_URL);

Start Déjà qu, ideally right after the server starts.

dq.start();

Step 2: Profit

Get a queue

const q = dq.getQueue('timeline', user1);

Create and add a message that expires in 24 hours

const Message = require('deja-qu').Message;

const msg = new Message('Have I seen this before?', 86400);

q.push(msg);

Get the first 5 messages

const messages = await q.get(0, 4);

Delete the oldest message

const message = await q.pop();

Debugging

Add DEBUG=deja-qu to the node start script in package.json to see debug output. i.e:

DEBUG=deja-qu node server.js

Tests

yarn install # or npm install
npm test

Author

Shane Vitarana :: http://shanev.me :: @shanev

Keywords

FAQs

Package last updated on 17 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc