redis/redis

Subscribe a channel but execute a lua script with the result

txgruppi opened this issue · 6 comments

It would be nice to have a command where you can subscribe to a channel but instead of receiving the value of the "event" it would go to a saved lua script.

It would be useful for me because I would like to do some processing after certain events, specially keyevents.

Create a channel+script subscription
SSUBSCRIBE [channel] [script name or sha]

Each command from pub/sub family would have its script version.

Something like: https://matt.sh/advanced-redis-pubsub-scripts

That's almost everything one needs to have database triggers - a great
suggestion that makes a lot of sense IMO.

On Fri, Apr 24, 2015 at 6:37 PM, Tarcísio Gruppi notifications@github.com
wrote:

It would be nice to have a command where you can subscribe to a channel
but instead of receiving the value of the "event" it would go to a saved
lua script.

It would be useful for me because I would like to do some processing after
certain events, specially keyevents.

Create a channel+script subscription
SSUBSCRIBE [channel] [script name or sha]

Each command from pub/sub family would have its script version.

Something like: https://matt.sh/advanced-redis-pubsub-scripts


Reply to this email directly or view it on GitHub
#2540.

Itamar Haber | Chief Developers Advocate
_Redis Watch Newsletter http://redislabs.com/redis-watch-archive *-
Curator and Janitor
*Redis http://www.redislabs.com/_*Labs http://www.redislabs.com/
*- Enterprise-Class
Redis for Developers

Mobile: +1 (415) 688 2443
Mobile (IL): +972 (54) 567 9692
Email: itamar@redislabs.com
Skype: itamar.haber

Blog http://redislabs.com/blog/ | Twitter
https://twitter.com/redislabsinc/ | LinkedIn
https://www.linkedin.com/company/redis-labs-inc

https://www.redislabs.com/company/redis-labs-careers

Good catch.

@itamarhaber this is the main idea. I want to react to certain events. When a key with a specific pattern or prefix is removed I would like to log something to some other key inside Redis.

In the same context, @lamby's #2319 also ties (expiration) events to Lua scripts - could be interesting when arbitrary or keyspace messages trigger custom behavior.

Suor commented

This could be used to maintain intermal redis database structure under semi-random deletes like maxmemory eviction.

Hello. This kind of features sound kinda nice but the complexity they add to Redis is pretty crazy sometimes, as they have to play well with a number of things like expires, AOF, replication, cluster.
Moreover this means to bind the Pub/Sub layer with the key space layer, which are currently pretty much separated things in Redis. I can see how this could be useful in certain use cases, but I can definitely see how this is going to make Redis less modular and more complex to handle, so I'm skeptic.

For this to be evaluated, we would need some serious use case analysis, reasoning on how this would play well with all the other subsystems of Redis, and a rationale about other alternatives are a bad idea, posted in the Redis development group for discussion. This does not provide guarantee for the feature to be accepted, but at least such an analysis would open a large discussion on this feature resulting in some verdict both from the community and from myself that we can use to move forward (either by banning the feature for the next years or by implementing it).