two questions about lua scripting

81 views
Skip to first unread message

Xiangrong Fang

unread,
Jul 26, 2012, 9:50:22 PM7/26/12
to redis-db
Hi All,

1) Is there a sha1 function?  I read here: http://antirez.com/m/p.php?i=234 about sha1(), but seems not available?

2) I need to write current time to a hash's field (as an object's last updated timestamp), but TIME is not allowed in writing context. I can use an external time source, but why on earth is this decision? What consequence will there be, if we can call TIME in lua scripting?

Thanks,
Shannon

--


Arek Bochinski

unread,
Jul 27, 2012, 12:01:24 AM7/27/12
to redi...@googlegroups.com
redis.sha1hex(string) will return a hex digest. https://github.com/antirez/redis/blob/unstable/src/scripting.c#L508



--


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.

Sebastian

unread,
Jul 27, 2012, 7:41:28 AM7/27/12
to redi...@googlegroups.com
About the time, I'm pretty sure that's because of replication. If the time is a parameter it can be replicated, but if the time is read from the OS every time the results will be different. The same thing applies to random parameters.

Xiangrong Fang

unread,
Jul 29, 2012, 9:48:25 PM7/29/12
to redi...@googlegroups.com
I still don't understand why replication is a problem. On the EVAL document page there is a demo on generating random keys, by calling math.random() in lua.   Since it is "random" why Redis insist that Master and Slave must hold the same data?

2012/7/27 Sebastian <sepp...@gmail.com>



--


Reply all
Reply to author
Forward
0 new messages