I think you should check out this link:
https://raw.githubusercontent.com/redis/redis/7.0/redis.conf
and look for notify-keyspace-events option. This will allow you to have a script (for example in Python) that listens to given type of events (utilizing the pub-sub layer) and does whatever you need it to do.