Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:01
    alavers commented #1080
  • 09:11
    amirmuminovic commented #711
  • 00:47
    visitsb commented #711
  • Mar 31 19:31
    alavers opened #1089
  • Mar 31 13:45
    ion-willo commented #711
  • Mar 31 12:58
    visitsb commented #711
  • Mar 31 11:05
    lenovouser commented #977
  • Mar 31 10:48
    JamesJGoodwin opened #1088
  • Mar 31 09:08
    aalimovs commented #1042
  • Mar 30 12:03
    shizhx commented #1007
  • Mar 30 11:45
    shizhx commented #1007
  • Mar 30 11:41
    shizhx commented #1007
  • Mar 30 11:40
    shizhx commented #1007
  • Mar 30 11:39
    shizhx commented #1007
  • Mar 30 11:39
    shizhx commented #1007
  • Mar 30 06:18

    luin on master

    fix: dismiss security alerts fo… (compare)

  • Mar 30 06:14

    luin on master

    docs: update funding.yml (compare)

  • Mar 30 04:13
    cokeeffekt commented #1080
  • Mar 30 03:25
    david1025 opened #1087
  • Mar 29 16:24
    ssdk86 commented #1082
Jason Shin
@JasonShin
  • enable the notification
  • redis.subscribe('EXPIRE', () => {})
Christian Roy
@roychri
Something like that, but it's not on EXPIRE that you will subscribe, but something like :__keyevent@0__:expire where 0 is the db. And the value you will get in the messag will be the name of the key that expire.
Jason Shin
@JasonShin
ok cool
thanks
do you know how to enable Redis Keyspace Notifications using https://hub.docker.com/_/redis?
Christian Roy
@roychri
Docker!!! :heart_eyes_cat: sure, one sec.
Jason Shin
@JasonShin
=)
thank you so much~~
Christian Roy
@roychri
You mount your own redis.conf file (volume) and you change the CMD to pass that config file.
Go down to "Additionally, If you want to use your own redis.conf" on that link you just gave me for an example.
notify-keyspace-events xK to only enable expired events
I found this
do you just include that line in the file
and mount it?
Christian Roy
@roychri
If you use that image (and not the one you first showed me) then yes.
But that image is not the official image
If you use the official image, just make an empty file with that one line, mount it and change CMD to use your file
OR, you could also enable it by your app
once connected send CONFIG SET notify-keyspace-events xK
and that will enable it
without having to mount any file
Jason Shin
@JasonShin
yeah right
i chose the config mount approach
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