fancy
fancy

Reputation: 51463

Can you use Lua scripting to make Redis throw events?

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!

Upvotes: 0

Views: 786

Answers (2)

Fritzy
Fritzy

Reputation: 1014

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.

Upvotes: 1

Sripathi Krishnan
Sripathi Krishnan

Reputation: 31538

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

Upvotes: 0

Related Questions