Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
cron-redis
Advanced tools
Inspired by the bull
var redisConfig = {
host: '127.0.0.1',
port: 6379,
db: 1,
password: 'root',
// other redis config
};
const queue = require('cron-redis')('test', redisConfig);
var moment = require('moment');
function hello (x, y){
console.log(new Date());
console.log(x + ' + '+ y +' = %s', x+y);
}
var task1 = {
method: hello.name,
params: [2, 3],
rule: moment().add(3, 's').toDate()
}
var task2 = {
method: hello.name,
params: [4, 5],
rule: '* */1 * * * *'
}
queue.register(hello)
queue.publish(task1);
queue.publish(task2);
init config
{
host: '127.0.0.1',
port: 6379,
DB: 1,
opts: {
auth_pass: 'root',
password: 'root'
}
}
register a task
method {Function | Object} // method for cron task callback
function hello (){
console.log('hello');
}
queue.register(hello);
or
var methods = {
hello: function(){
console.log('hello');
},
// and more
}
queue.register(methods);
add a task to queue
method {String} the name of method will be callback.
params {Array}
rule {options} cron rule . {Date} or {* */1 * * * *}
desc {options} description for task
uniqueID {options} keep task unique in queue
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, optional)
or
new Date();
moment().add(3, 's').toDate()
the queue task in redis
[{ data: '{"method":"hello","params":[4,5],"rule":"* */1 * * * *"}',
opts: '{"delay":60000}',
progress: '0',
delay: '0',
timestamp: '1458008690942',
attempts: '1',
attemptsMade: '1',
stacktrace: '[]',
returnvalue: 'undefined',
key: 'bull:test:111' },
]
delete some hash key
FAQs
cron task for node by redis
The npm package cron-redis receives a total of 7 weekly downloads. As such, cron-redis popularity was classified as not popular.
We found that cron-redis 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.