Is there any quick command in REDIS which allows me to do the following
I want to set the Value of key Y equal to the value of Key X .
How do I go about doing this from the Redis Client .
I use the standard Redis-cli client .
Basically I am looking for some equivalent of the following –
Y.Val() = X.Val()
You can do this with a Lua script:
The example below uses SCRIPT LOAD to create the script and invokes it using EVALSHA passing the following arguments:
Output:
It does appear to be a lot of stuff compared to simply doing a GET and then s SET, but once you’ve loaded the script (and memorized the SHA1) then you can reuse it repeatedly.