skip to Main Content

Lets say a Redis node is configured with an eviction policy of LRU. Whenever an key-eviction takes place, is there way to know which keys are evicted?

Using this information, I would like to build a system where evicted keys are streamed to another database.

2

Answers


  1. Did you take a look at Redis keyspace notifications. https://redis.io/docs/manual/keyspace-notifications/

    Login or Signup to reply.
  2. With the RedisGears module you can react to these keyspace notifications.

    In RedisGears 2 you can register your consumer, and then push information from there to the stream. But this is happening after the eviction has happened.

    //Second argument is to set a prefix for keys you want to filter on
    redis.register_notifications_consumer("eviction_consumer", "", function(client, data) {
        //Do checks here
        
        client.call('XADD', data.key, ...);
    });
    

    There is an extensive get started in the RedisGears repository.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search