3

I am using Redis Cloud addon for one of my Heroku java app. I want to listen to key space events from my app. I tried setting the config on Jedis client, but I am not getting any notifications

    URI redisUri = new URI(REDIS_CLOUD_URL);
    JedisPool pool = new JedisPool(new JedisPoolConfig(),
            redisUri.getHost(),
            redisUri.getPort(),
            Protocol.DEFAULT_TIMEOUT,
            redisUri.getUserInfo().split(":",2)[1]);
    pool.getResource().getClient().configSet("notify-keyspace-events", "K$");

While using embeded redis server, i do the following and I get the notifications.

    RedisServer redisServer = RedisServer.builder().port(6379)
            .setting("notify-keyspace-events K$")
            .build();
    redisServer.start();

I want to set the similar config on Redis Cloud. Is there a CLI to Redis Cloud or a Jedis API to do the same?

Kolli
  • 41
  • 6

1 Answers1

0

You can change some Redis configuration at runtime. I recommend setting the config variable as soon as your app fires up via your Redis client: (node_redis example:)

var client = redis.createClient();
client.config("SET", "notify-keyspace-events", "K$");

To see what events you can specify, take a look here: Redis-Notifications

Ian
  • 3,806
  • 2
  • 20
  • 23