Intercepting keyspace/keyevent notifications in LUA script

As mentioned in Redis Keyspace Notifications – Redis,

In the future there are plans to allow for more reliable delivering of events, but probably this will be addressed at a more general level either bringing reliability to Pub/Sub itself, or allowing Lua scripts to intercept Pub/Sub messages to perform operations like pushing the events into a list.

I wanted to intercept expiry events in golang but as it is less reliable due to its fire and forget nature, I want to intercept those messages in lua script as mentioned in official documentation.

What I read till now is we can’t subscribe to events in LUA , then how can we intercept those messages at expiry of TTL? Thanks for the help.

Hi there,

Actually, the best way to solve this now (apart from subscribing in your app) is to use RedisGears. You can write a function that will persist these messages to a stream. See here: https://oss.redis.com/redisgears/

Kyle