swatantra / redis

Automatically exported from code.google.com/p/redis
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[Feature Request] Hooks, plugins or script support. #222

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
It would be extremely useful to have some hooks so that some custom 
functionality could be added. For example, hooks provided at following 
places could be powerful and open up many new use cases for those who want 
it, without reducing the efficiency of core redis.

1. Before and after execution of any command.
2. When a key's TTL expires.
3. When certain thresholds are met in statistics collection.
4. On Channel Open / Close, etc.,

Some or all of these extension points, could lead to many interesting use 
cases for redis.

Thoughts?

Original issue reported on code.google.com by vinuth.m...@gmail.com on 2 Apr 2010 at 8:08

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
yes, add some sort of listener/observer mechanism :
- when a key is updated
- when a key is deleted
- when a key value changes
- ...

or give new commands such as (inspired from the pubsub mechanism):
NOTIFY_ON_SET key            --> ex: NOTIFY_ON_SET "myclass:myobject:myfield"
NOTIFY_ON_CHANGE key
NOTIFY_ON_CREATE key
NOTIFY_ON_DELETE key

eventually
NOTIFY_ON_MATCH key regexp   --> ex: NOTIFY_ON_MATCH mykey "^[0-9]+.*"
NOTIFY_ON_EXPR key boolexpr  --> ex: NOTIFY_ON_EXPR mykey ($self == "ERROR")

could also add regexp alternatives
RNOTIFY_ON_CHANGE regkey     --> ex: RNOTIFY_ON_CHANGE "myclass:myobject:.*"

IMHO: PUBLISH/SUBSCRIBE is useless if not related to GET/SET

Original comment by philippe...@gmail.com on 1 May 2010 at 4:27

GoogleCodeExporter commented 8 years ago
any updates?

Original comment by camilo.a...@gmail.com on 13 Jan 2011 at 4:57

GoogleCodeExporter commented 8 years ago
I've done a quick sketch of how Lua scripts could be added to redis. You can 
view the diff here:
https://github.com/georgebashi/redis/compare/master...lua-scripts

Don't try it out unless you're very brave, but it adds a "LUAEXEC" command 
which lets you run arbitrary Lua code, and adds a Lua function "redis()" which 
lets you call commands and receive back responses in protocol format. For 
example, from redis cli:
redis> luaexec "redis('incrby', 'a', '5') ; return '+OK'"
+OK
redis> get a
"5"

As I said, this is a very early version - I've done some more work since, 
tidying up the interface a bit, but haven't yet had the time to tidy up and 
push that to Github - if anyone's interested, I'd be happy to do so over the 
weekend.

When I spoke to Pieter about the patch on IRC, he raised the point about how 
having code running server-side would interact with all the features like 
replication, sharding, aof, etc. I'd be interested to hear opinions on it.

Cheers,

George

Original comment by zin...@gmail.com on 13 Jan 2011 at 5:32

GoogleCodeExporter commented 8 years ago
I too would love to see this, possibly with the option of loading the scripts 
from disk as opposed to receiveing them over the wire

Original comment by yamac...@gmail.com on 4 May 2011 at 4:03