Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 19:57
    stale[bot] labeled #1031
  • 19:57
    stale[bot] commented #1031
  • 19:57
    stale[bot] labeled #1043
  • 19:57
    stale[bot] commented #1043
  • 05:35
    BorntraegerMarc review_requested #1063
  • 05:35
    BorntraegerMarc opened #1063
  • 02:18
    jeremytm opened #1062
  • Feb 16 15:14
    stale[bot] labeled #1042
  • Feb 16 15:14
    stale[bot] commented #1042
  • Feb 15 20:37
    katesroad commented #159
  • Feb 15 15:10
    ahkong0429 edited #1061
  • Feb 15 15:10
    ahkong0429 opened #1061
  • Feb 15 11:19
    stale[bot] closed #1024
  • Feb 15 10:37
    franckboudraa closed #1060
  • Feb 15 10:13
    franckboudraa commented #1060
  • Feb 15 10:01
    franckboudraa commented #1060
  • Feb 15 09:33
    franckboudraa edited #1060
  • Feb 15 09:33
    franckboudraa commented #1060
  • Feb 15 08:33
    franckboudraa opened #1060
  • Feb 14 11:49
    stale[bot] labeled #1046
Jason Shin
@JasonShin
but having a problem
Christian Roy
@roychri
This is a docker discussion, not an ioredis discussion... mind to continue this in docker/docker room?
Jason Shin
@JasonShin

I've mounted redis.conf to /usr/local/etc/redis/redis.conf

and it contains notify-keyspace-events Ex

Code:

redis.set('test', 12, 'EX', 1);
console.log(await redis.get('test')); // return 12
redis.subscribe('__keyevent@0__:expire', (x, y, c, v, b) => {
    console.log('zz', x, y, c, v, b);
});

The console.log return zz null 1 undefined undefined undefined for the first time then errors

error: Connection in subscriber mode, only subscriber commands may be used
error: Error: Connection in subscriber mode, only subscriber commands may be used
sorry this is more of an ioredis question I believe
Christian Roy
@roychri
oh, yes it is. sorry.
So the error message says it.
You cannot use "subscribe" on the same connection that you use other commands.
Make a new connection for your subscribe.
redisSubscribe = new Redis();
or whatever
Jason Shin
@JasonShin
ahh right
Jason Shin
@JasonShin
hey @roychri I still do not receive any subscribe event for the key expire
what's wrong with above code?
Creating a new instance as redisSubscriber resolved the connection issue
however, there's no expire events received in the subscribe block
Christian Roy
@roychri
Are you using docker run or docker-compose or something else?
Jason Shin
@JasonShin
I'm using docker compose
Christian Roy
@roychri
docker-compose exec redis-master redis-cli config get notify-keyspace-events
Replace redis-master with the name of the redis service in your compose file. What do you get?
Jason Shin
@JasonShin
1) "notify-keyspace-events"
2) ""
ahh...
T_T !!
im dumb
Christian Roy
@roychri
Did you change the command in your docker-compose.yaml ?
Jason Shin
@JasonShin
nope
Christian Roy
@roychri
You have to tell redis to use your new config file
Jason Shin
@JasonShin
yeah right
1) "notify-keyspace-events"
2) "xE"
ok cool
Christian Roy
@roychri
I do not think xE will send the __keyevent@0__:expire event but rather the __keyevent@0__:test event (with the name of your key in the event name).
If you want __keyevent@0__:expire then you should set it to xK I think.
Jason Shin
@JasonShin
I see
Christian Roy
@roychri
But Maybe your right and im mixing them up, tias
Jason Shin
@JasonShin
still, no events
1) "notify-keyspace-events"
2) "xK"
Christian Roy
@roychri
and no events with xE either?
Jason Shin
@JasonShin
nope
I only get a very first
zz null 1 undefined undefined undefined
which means nothing
it's from
redis2.subscribe('__keyevent@0__:expired', (x, y, c, v, b) => {
    console.log('zz', x, y, c, v, b);
  });
^^ testing code
Christian Roy
@roychri
Enable all events (AKE instead of xK) and in another terminal use redis-cli monitor to see the events being sent after you docker-compose restart app...
Jason Shin
@JasonShin
1550539085.729667 [0 192.168.0.3:56496] "info"
1550539085.750826 [0 192.168.0.3:56498] "info"
1550539085.751758 [0 192.168.0.3:56498] "set" "test" "12" "EX" "1"
1550539085.751925 [0 192.168.0.3:56498] "set" "test" "12" "EX" "2"
1550539085.752053 [0 192.168.0.3:56498] "subscribe" "__keyevent@0__:expired"
after that, nothing fires inside the subscribe code
Christian Roy
@roychri
Using redis 2.8.0 or later?
Jason Shin
@JasonShin
yeah
I'm using 5.0.0
Christian Roy
@roychri
I recommend you read this again and see if you missed anything...
https://redis.io/topics/notifications
Jason Shin
@JasonShin
ok I will do that
@roychri a quick question, how do you listen to all these events using cli?
I just want to test this without ioredis