Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
redis-message-queue
Advanced tools
Note: This is A node.js package for regarding redis as a message queue, npm repo: https://www.npmjs.com/package/redis-message-queue
$ npm install redis-message-queue
There are two kinds of queue - normal queue and unique queue.
Each value in unique queue is unique. If a new value that equals any value in the queue, you may choose to update or not.
First you should require this package:
var rmq = require("redis-message-queue");
var normalQueue = new rmq.NormalQueue(QUEUE_NAME, [...]);
Note:
[...]
is the option(s) to connect redis server. Refer to node-redis document.Eg.
new rmq.NormalQueue(QUEUE_NAME, 6379, '127.0.0.1', {}); new rmq.NormalQueue(QUEUE_NAME, unix_socket, options); ...
To Select a db :
normalQueue.select(db, function() {
console.log("db select success");
});
To push a message to your queue, you may use this function:
normalQueue.push("YOUR MESSAGE", function(err) {
console.log(err);
});
To get message(s) from your redis queue, you may use get
function.
normalQueue.get(function(err, messages) {
console.log(err);
if(messages.length) console.log(messages[0]);
});
// This call gets 10 earlist messages
normalQueue.get(10, function(err, messages) {
console.log(err);
for(var i = 0; i < messages.length; i++) console.log(messages[i]);
});
normalQueue.get(-1, function(err, messages) {
console.log(err);
for(var i = 0; i < messages.length; i++) console.log(messages[i]);
});
To remove message(s) from your redis queue, you may use removeAmount
function.
normalQueue.removeAmount(function(err) {
console.log(err);
});
normalQueue.removeAmount(5, function(err) {
console.log(err);
});
normalQueue.removeAmount(-1, function(err) {
console.log(err);
});
Get the length of current queue.
normalQueue.length(function(err, len) {
console.log(len);
});
Each message in unique queue is unique.
var uniqueQueue = new rmq.UniqueQueue(QUEUE_NAME, [...]);
Note:
[...]
is the option(s) to connect redis server. Refer to node-redis document.Eg.
new rmq.UniqueQueue(QUEUE_NAME, 6379, '127.0.0.1', {}); new rmq.UniqueQueue(QUEUE_NAME, unix_socket, options); ...
To Select a db :
normalQueue.select(db, function() {
console.log("db select success");
});
Push a message to the queue.
This call will check if your message is existing. If existing, it will move the previous message to the end of queue. Otherwise, your message will be pushed at the end of queue.
uniqueQueue.push("YOUR_MESSAGE", true, function(err) {
console.log(err);
});
This call will check if your message is existing. If existing, it won't do anything. Otherwise, your message will be pushed at the end of queue.
uniqueQueue.push("YOUR_MESSAGE", function(err) {
console.log(err);
});
// or you can do this
uniqueQueue.push("YOUR_MESSAGE", false, function(err) {
console.log(err);
});
uniqueQueue.get(function(err, messages) {
console.log(err);
if(messages.length) {
console.log(messages[0].message);
console.log(messages[0].updatedAt);
}
});
uniqueQueue.get(3, function(err, messages) {
console.log(err);
for(var i = 0; i < messages.length; i++) {
console.log(messages[i].message);
console.log(messages[i].updatedAt);
}
});
uniqueQueue.get(-1, function(err, messages) {
console.log(err);
for(var i = 0; i < messages.length; i++) {
console.log(messages[i].message);
console.log(messages[i].updatedAt);
}
});
Refer to remove section in Normal Queue.
Remove one or more certain message(s) in the queue.
uniqueQueue.get(10, function(err, messages) {
for(var i = 0; i < 5; i++) messages.shift();
// Remove Messages
uniqueQueue.removeMessages(messages, function(err, removeCount, notRemovedMessages) {
console.log(err);
console.log(removeCount);
for(var i = 0; i < notRemovedMessages.length; i++) console.log(notRemovedMessages[i].message);
});
});
Refer to length section in Normal Queue.
Delete this queue key and values in redis.
uniqueQueue.deleteQueue(function() {});
normalQueue.deleteQueue(function() {});
Let the queue object disconnect from redis server and let this instance can't do any other thing any more.
uniqueQueue.destroy();
normalQueue.destroy();
You're welcome to pull requests!
FAQs
Redis Message Queue Middleware inspired by XadillaX
We found that redis-message-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.