Giter VIP home page Giter VIP logo

Comments (9)

sundb avatar sundb commented on May 20, 2024

@Prem-Kumar-98 can you share your test code?
from my testing it's generally not a redis issue, maybe relate to client.

from redis.

Prem-Kumar-98 avatar Prem-Kumar-98 commented on May 20, 2024

Hi @sundb ,
Below is the code snippet for the test method as requested. I've replaced sensitive information with generic placeholders for confidentiality:

Class exampleFileName(){

Constructor() {
    this.client = RedisInstance.getRedis();
    this.redisService = RedisSubscriberClient.getRedis();
}

async testMethod() {
  await this.client.unsubscribe("__keyspace@0__:" + timerKey);
  await this.redisService.setex("__keyspace@0__:" + timerKey, 60);
  this.client.subscribe("__keyspace@0__:" + timerKey, (message, channel) => {
    console.log("Testing event triggered", message, channel);
  }).then((response) => {
    log.info("Timer set! " + response);
  });
}
}

Let me know if you need further assistance or clarification.
I have a question regarding the behavior of a node-redis client. If a node-redis client subscribes to a channel twice with different instances, will it emit the expired event twice?

from redis.

sundb avatar sundb commented on May 20, 2024

I have a question regarding the behavior of a node-redis client. If a node-redis client subscribes to a channel twice with different instances, will it emit the expired event twice?

yes, they are two connections.

from redis.

Prem-Kumar-98 avatar Prem-Kumar-98 commented on May 20, 2024

So, as you can see, i'm unsubscribing the channel before subscribing to it. In this case, why is the expired event emitting twice in the rarest case?

from redis.

sundb avatar sundb commented on May 20, 2024

@Prem-Kumar-98 can you share the notificatiions you received?

from redis.

Prem-Kumar-98 avatar Prem-Kumar-98 commented on May 20, 2024

Hi @sundb , I don’t have logs or notification details. I'm using GCP Redis Labs, and I could see the subscribed callback got triggered twice.

  this.client.subscribe("__keyspace@0__:" + timerKey, (message, channel) => {
    console.log("Testing event triggered", message, channel);
  })

from redis.

sundb avatar sundb commented on May 20, 2024

@Prem-Kumar-98 what's your config notify-keyspace-events?
first at all, if you are using KEA, the script you give will receive three notification:

__keyspace@0__k set
__keyspace@0__k expire
__keyspace@0__k expired

from redis.

Prem-Kumar-98 avatar Prem-Kumar-98 commented on May 20, 2024

@sundb ,Keyspace event I configured the cloud service and verified that with the configuration I have from my end, it will emit the event only for expired, because it's not happening all the time; in the rarest case, it's emitting the expired events twice.

from redis.

sundb avatar sundb commented on May 20, 2024

@Prem-Kumar-98 sorry, from the clues i don't know the reason.
go through the code, the expired notification was just send from one place, at the same we will remove it from the database.
i don't think one key can be expred two times.

from redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.