3 ms·
I think there needs to be some way to store scripts on the server. I like the CouchDB method of a storing a view as a special document. Could use a Hash to stor
by mumrah 15y ago
I think there needs to be some way to store scripts on the server. I like the CouchDB method of a storing a view as a special document. Could use a Hash to store the code along with metadata (version, last modified, etc).
That said, if Redis can EVAL a script stored as a String or a Hash->Key, the client can deal with registering and versioning scripts.
Awesome work btw - been looking forward to scripting in Redis for a long time
- almost 15y agoHave a look at the bottom of the article, antirez suggests that a EVALSHA command might be implemented that would allow specification of a script by a SHA1 hash. Seems like a good idea to get the rest of it sorted before deciding on that bit though.
- deleted 15y ago[deleted]
- StavrosK 15y agoThat's what I was thinking as well. The question is, can redis (or lua, I guess) eval a script stored as a string? I imagine you would issue a redis EVAL where the script would be the Lua "eval(mykey)", is that possible? Basically, 1) does Lua have an "eval" statement and 2) can Redis' EVAL read keys (I assume it can, since that's pretty much what the post says)?
- unsigner 15y ago1) yes, it has, loadstring() turns a string into an anonymous function which can then be called at will. 2) yes So it seems you can set up your own stored procedures.
- brianm 15y agoTokyo Tyrant (and Kyoto Tyrant) have a pretty nice mechanism for doing this, http://fallabs.com/tokyotyrant/spex.html#luaext http://fallabs.com/tokyotyrant/spex.html#luaext Basically you give it a "-ext /path/to/waffles.lua" arg at startup to define a bunch of user defined functions.
- antirez 15y agoThis is the obvious choice, but we are in the cloud now ;) I feel like it's better if all the instances are the same regardless of the configuration. That's the whole point for not taking this path.
- brianm 15y agoEven in the magical cloud, you still have configuration -- listening port at a minimum. Cloud does not remove need for deployment management, as a rule.
- moe 15y agoWhy do you argue against someone who's set to go the extra-mile to make life easier for us? Inflexible configuration mechanisms are one of the top pain points in cluster-environments (cloud or not). Kudos to antirez for realizing that and working against it.
- brianm 15y agoI don't see how your argument follows, but... there is nothing "inflexible" about that setup, imho. I think antirez has a pretty good setup, but without poking around for edges, you won't find the edges :-)
- brianm 15y agoOkay, learning more about it via another channel, I am pretty convinced of the path you took :-)