question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redis Cluster keyPrefix doesn't work in redisOptions

See original GitHub issue

version: 4.14.1 According to doc, I think keyPrefix in redisOptions. But it doesn’t work. Like blow:

const redisClient = new Redis.Cluster(nodes, {
  redisOptions: {
    keyPrefix: 'foo:',
  }
});

After attempts, it actually works in root option, like this:

const redisClient = new Redis.Cluster(nodes, {
    keyPrefix: 'foo:',
});

Is it by design?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:8

github_iconTop GitHub Comments

3reactions
aaronleesmithcommented, Oct 21, 2020

This issue was left to die on the vine with an open PR, but it is critical to the functionality of key prefixing. The workaround is to include keyPrefix one level up (on the object which is the second parameter to new Cluster) but the type definitions will yell at you for trying to do that. So you end up having to do something like this:

new Cluster(nodes, clusterRetryStrategy: { this.clusterRetryStrategy,
      redisOptions: {
        maxRetriesPerRequest: 1,
        keyPrefix: `${this.config.RedisNamespace}:`,
      },
      /**
       * The entry below fixes a bug where the keyPrefix is totally ignored when used in cluster mode.
       * The issue has an open PR: https://github.com/luin/ioredis/issues/1024
       */
      keyPrefix: `${this.config.RedisNamespace}:`
} as any)

It would be great if this PR were merged and this was resolved.

0reactions
glensccommented, Oct 10, 2022

would be nice if the fix be ported to 4.x

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the ioredis.Cluster function in ioredis - Snyk
Cluster examples, based on popular ways it is used in public projects. ... var options = { keyPrefix: config.redis_prefix, password: config.redis_password }; ...
Read more >
Redis (node using ioredis) clusterRetryStrategy exception ...
I have a local setup on a mac running a redis cluster with 6 nodes. ... slotsRefreshInterval: 10000, redisOptions: { keyPrefix: this.
Read more >
nestjs-redis-cluster - npm
Start using nestjs-redis-cluster in your project by running `npm ... There are no other projects in the npm registry using nestjs-redis-cluster.
Read more >
API - ioredis - Read the Docs
While loading, the server not respond to any commands. To work around this, when this option is true , ioredis will check the...
Read more >
Configuration | StackExchange.Redis
We run this command to verify that we have a valid connection to the Redis ... a serviceName in the connection string, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found