New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nerimity/mimiqueue

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nerimity/mimiqueue

NodeJS group queuing library. Requires Redis.

  • 1.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
182
increased by19.74%
Maintainers
0
Weekly downloads
 
Created
Source

Mimiqueue

Installation

pnpm i redis @nerimity/mimiqueue

Usage

import { createClient } from "redis";
import { Queue } from "@nerimity/mimiqueue";
import { setTimeout } from "timers/promises";

const redisClient = createClient({
  socket: {
    host: "127.0.0.1",
    port: 6379,
  },
});

await redisClient.connect();
await redisClient.flushAll();

const addFriendQueue = new Queue({
  redisClient,
  name: "addFriend",
  process: async (data) => {
    await setTimeout(2000);
    return { done: "lol", data };
  },
});

addFriendQueue.add({ someData: 1 }, { groupName: "1234" }).then((res) => {
  console.log(res);
});
addFriendQueue.add("hello", { groupName: "1234" }).then((res) => {
  console.log(res);
});
addFriendQueue.add(123).then((res) => {
  console.log(res);
});

Alt Usage

import { createClient } from "redis";
import { AltQueue } from "@nerimity/mimiqueue";
import { setTimeout } from "timers/promises";

const redisClient = createClient({
  socket: {
    host: "127.0.0.1",
    port: 6379,
  },
});

await redisClient.connect();
await redisClient.flushAll();

const queue = new AltQueue({
  redisClient,
  name: "addFriend",
});

async function doSomething(groupName) {
  const done = await queue.start({ groupName });
  console.log("doing something");
  await setTimeout(1000);
  done();
}

doSomething("123");
doSomething("123");

Alt 2 Usage

import { createClient } from "redis";
import { AltQueue2 } from "@nerimity/mimiqueue";
import { setTimeout } from "timers/promises";

const redisClient = createClient({
  socket: {
    host: "127.0.0.1",
    port: 6379,
  },
});

await redisClient.connect();
await redisClient.flushAll();

const queue = new AltQueue2({
  redisClient,
  name: "addFriend",
});

async function queueDoSomething(groupName) {
  queue.add(() => doSomething(groupName), { groupName });
}

async function doSomething(groupName) {
  console.log("doing something");
  await setTimeout(1000);
}

queueDoSomething("123");
queueDoSomething("123");

FAQs

Package last updated on 26 Sep 2024

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