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.

ioRedis can't delete key in redis cluster

See original GitHub issue

Configurations

ioRedis@4.9.0 (cluster mode) connect-redis@3.4.1 express-session@1.15.6 Redis Server Version: 5

Errors

ReplyErrorredis-parser.lib:parser in parseError errorCROSSSLOT Keys in request don’t hash to the same slot

the Reply errors contains :

{ command: { args: [ sess:6BSHHdpoqDVhpqWuOqrunZcqsUadtSEn, ], name: del } }

My code

const express = require('express');
const session = require('express-session');
const Redis = require('ioredis');

redisClient = new Redis.Cluster([{ 'host': host, 'port': port }]); 
const RedisStore = require('connect-redis')(session);

let sessionStore = new RedisStore({
    client: redisClient
});

app.use(session({
    secret: 'mysecret',
    saveUninitialized: false,
    resave: false,
    store: sessionStore,
    cookie: {
        maxAge: 60 * 1000 // 1 minutes 
    }
}));

Logs

connect:redis DEL “Nu-53UpCkkG4XutUUFULWlWH_s-M2IU9” ioredis:redis write command[10.2.0.29:6379]: 0 -> del([ ‘sess:Nu-53UpCkkG4XutUUFULWlWH_s-M2IU9’, ‘’ ])

After seeing that I suppose that ioredis add a blank parameters and this is why it can’t delete my session key.

What is expected ?

I expect that my session key will be deleted in my redis cluster.

Thank in advance for your reply 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
luincommented, Jul 19, 2019

Fixed in connect-redis@v3.4.2.

1reaction
luincommented, Jul 19, 2019

I’ve created a pull request on the connect-redis repo for this issue: https://github.com/tj/connect-redis/pull/272

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to delete keys matching a pattern in Redis Cluster
Answers for that question try to remove multiple keys in a single DEL . However, keys matching the given pattern might NOT locate...
Read more >
DEL
When a key to remove holds a value other than a string, the individual complexity for this key is O(M) where M is...
Read more >
ioredis
A robust, performance-focused and full-featured Redis client for Node.js.. Latest version: 5.2.4, last published: 2 months ago.
Read more >
Redis Delete Key
Before we learn how to delete keys, let us first discuss creating keys and inserting data in Redis. Open the terminal and open...
Read more >
How to Clear Redis Cache {Deleting All Keys or from ...
Redis is an open-source solution for storing key-value pairs. Here is how you can delete those keys and clear Redis cache.
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