0

I'm trying to create an abstraction where I can listen to change events of a redis collection and have the key, value passed into a callback. I was wondering if it would be possible to do this with Lua scripting on the newer versions.

Thanks!

fancy
  • 48,619
  • 62
  • 153
  • 231

2 Answers2

1

You can certainly publish events from Lua scripts, and you could certainly poll. The right way to solve your problem would be to publish to a pubsub channel every time you change the set.

Fritzy
  • 1,014
  • 7
  • 7
0

No, you can't.

Since Redis is single threaded, your lua script must return quickly. Listening to change of events requires a long running process, and lua scripting is just not designed for that use case.

Take a look at my answer to your other question - listen for changes in redis

Community
  • 1
  • 1
Sripathi Krishnan
  • 30,948
  • 4
  • 76
  • 83