![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
node-redis-retry-strategy
Advanced tools
A custom implementation of the node_redis retry_strategy function.
Sometimes, if the Redis server is down, you need to have clients that don't give up and try to reconnect.
"node-redis-retry-strategy" is a function that returns the node_redis retry_strategy
function.
The strategy is: every wait_time
try to connect for number_of_retry_attempts
times (each time separated by delay_of_retry_attempts
).
By default, every 5 minutes, try 5 times to reconnect (every attempt is separated by 500 ms). It retries forever
.
* 2.0 breaking change
: by default do not allow to start the service without a redis connection; to have the previous behaviour set allow_to_start_without_connection
:true
# with npm
npm install node-redis-retry-strategy
# or with yarn
yarn add node-redis-retry-strategy
// redisClient.js file
var redis = require("redis");
var retryStrategy = require("node-redis-retry-strategy");
var client = redis.createClient({
host: "127.0.0.1",
port: 6379,
retry_strategy: retryStrategy()
});
module.exports = client;
// index.js file
var redisClient = require("redisClient.js");
redisClient.on("connect", function () {
console.log("connected!");
});
redisClient.on("end", function () {
console.log("redis connection has closed");
});
redisClient.on("reconnecting", function (o) {
console.log("redis client reconnecting", o.attempt, o.delay);
});
It accepts options object as a parameter with 4 possible keys:
type boolean
Default: false
2 possible scenarios:
false
if there is no connection when the service starts, end reconnecting throwing an error and flush all commandstrue
allow to start the service without a redis connectionvar redis = require("redis");
var retryStrategy = require("node-redis-retry-strategy");
var client = redis.createClient({
host: "127.0.0.1",
port: 6379,
retry_strategy: retryStrategy({
allow_to_start_without_connection: true
})
});
module.exports = client;
type number
msDefault: 5
The number of attempts separated by the delay_of_retry_attempts
. If set to 0, it ends reconnecting with the built in error.
var redis = require("redis");
var retryStrategy = require("node-redis-retry-strategy");
var client = redis.createClient({
host: "127.0.0.1",
port: 6379,
retry_strategy: retryStrategy({
number_of_retry_attempts: 7
})
});
module.exports = client;
type number
msDefault: 500
The delay between each retry attempts.
var redis = require("redis");
var retryStrategy = require("node-redis-retry-strategy");
var client = redis.createClient({
host: "127.0.0.1",
port: 6379,
retry_strategy: retryStrategy({
delay_of_retry_attempts: 1000
})
});
module.exports = client;
type number
msDefault: 300000
(5 min)
How long stop retrying to connect.
var redis = require("redis");
var retryStrategy = require("node-redis-retry-strategy");
var client = redis.createClient({
host: "127.0.0.1",
port: 6379,
retry_strategy: retryStrategy({
wait_time: 600000
})
});
module.exports = client;
FAQs
My custom node_redis retry_strategy function
The npm package node-redis-retry-strategy receives a total of 1,157 weekly downloads. As such, node-redis-retry-strategy popularity was classified as popular.
We found that node-redis-retry-strategy 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.