@nerimity/mimiqueue
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "@nerimity/mimiqueue", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "NodeJS group queuing library. Requires Redis.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.mjs", |
@@ -78,1 +78,36 @@ # Mimiqueue | ||
``` | ||
## Alt 2 Usage | ||
```ts | ||
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"); | ||
``` |
@@ -6,3 +6,3 @@ import { createClient } from "redis"; | ||
interface AltQueueOpts { | ||
export interface AltQueueOpts { | ||
name: string; | ||
@@ -9,0 +9,0 @@ redisClient: RedisClient; |
export * from "./Queue"; | ||
export * from "./AltQueue"; | ||
export * from "./AltQueue2"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47393
16
538
113