Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis move all keys from one database to another

Tags:

redis

Is there a command to move redis keys from one database to another or is it possible only with lua scripting??

There has been this type of question asked perviously redis move all keys but the answers are not appropriate and convincing for a beginner like me.

like image 961
Aarish Ramesh Avatar asked Jan 12 '23 17:01

Aarish Ramesh


1 Answers

u can use "MOVE" to move one key to another redis database;

the text below is from redis.io

MOVE key db

Move key from the currently selected database (see SELECT) to the specified destination database. When key already exists in the destination database, or it does not exist in the source database, it does nothing. It is possible to use MOVE as a locking primitive because of this.

Return value

Integer reply, specifically:

  • 1 if key was moved.
  • 0 if key was not moved.
like image 75
freedoo Avatar answered Jan 19 '23 01:01

freedoo