mirror of
https://github.com/fluencelabs/redis
synced 2025-06-19 20:21:21 +00:00
PSYNC2: just store script bodies into RDB.
Related to #4483. As suggested by @soloestoy, we can retrieve the SHA1 from the body. Given that in the new implementation using AUX fields we ended copying around a lot to create new objects and strings, extremize such concept and trade CPU for space inside the RDB file.
This commit is contained in:
@ -1147,11 +1147,26 @@ int redis_math_randomseed (lua_State *L) {
|
||||
*
|
||||
* f_<hex sha1 sum>
|
||||
*
|
||||
* If 'funcname' is NULL, the function name is created by the function
|
||||
* on the fly doing the SHA1 of the body, this means that passing the funcname
|
||||
* is just an optimization in case it's already at hand.
|
||||
*
|
||||
* The function increments the reference count of the 'body' object as a
|
||||
* side effect of a successful call.
|
||||
*
|
||||
* On success C_OK is returned, and nothing is left on the Lua stack.
|
||||
* On error C_ERR is returned and an appropriate error is set in the
|
||||
* client context. */
|
||||
int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) {
|
||||
sds funcdef = sdsempty();
|
||||
char fname[42];
|
||||
|
||||
if (funcname == NULL) {
|
||||
fname[0] = 'f';
|
||||
fname[1] = '_';
|
||||
sha1hex(fname+2,body->ptr,sdslen(body->ptr));
|
||||
funcname = fname;
|
||||
}
|
||||
|
||||
funcdef = sdscat(funcdef,"function ");
|
||||
funcdef = sdscatlen(funcdef,funcname,42);
|
||||
|
Reference in New Issue
Block a user