Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:25:34+00:00 2026-06-05T06:25:34+00:00

Is there any quick command in REDIS which allows me to do the following

  • 0

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()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:25:35+00:00Added an answer on June 5, 2026 at 6:25 am

    You can do this with a Lua script:

    redis.call('SET', KEYS[2], redis.call('GET', KEYS[1])); return 1;
    
    1. KEYS1 is the source key
    2. KEYS2 is the target key

    The example below uses SCRIPT LOAD to create the script and invokes it using EVALSHA passing the following arguments:

    1. The SHA1 returned from the script load
    2. a 2 for the number of keys that will be passed
    3. The source key
    4. The target key.

    Output:

    redis 127.0.0.1:6379> set src.key XXX
    OK
    redis 127.0.0.1:6379> get src.key
    "XXX"
    redis 127.0.0.1:6379> SCRIPT LOAD "redis.call('SET', KEYS[2], redis.call('GET', KEYS[1])); return 1;"
    "1119c244463dce1ac3a19cdd4fda744e15e02cab"
    redis 127.0.0.1:6379> EVALSHA 1119c244463dce1ac3a19cdd4fda744e15e02cab 2 src.key target.key
    (integer) 1
    redis 127.0.0.1:6379> get target.key
    "XXX"
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any quick guide/reference to list all the countries and its states/provinces? Like
is there any way of quick jump to the last modified line? eclipse has
A quick question, for a quick answer (since I'm not finding any): Is there
Hey just a quick question for any experts out there. I have a site
Hey guys, quick question for any experts out there. I am allowing users to
Hey guys, one more quick question for any experts out there. I have a
In Linux, Is there any command to move all sub directories created before a
Are there any quick way to map some IDataReader to object without third party
Is there any quick way converting <?xml version=1.0?><response><id>0123456</id><userid>0123</userid> to <?xml version=1.0?> <response> <id> 0123456
Is there any easy/quick way to yank into vim's last search register (/)? From

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.