Redis Keys: MOVE
MOVE key db
Redis MOVE command is used to move a key from currently selected database to 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.
Syntax:
MOVE KEY_NAME DESTINATION_DATABASE
Available since
1.0.0.
Return Value
-
Integer reply , specifically
- 1, if the key is moved.
- 0, if the key is not moved.
Return Value Type
Integer
Example: Redis MOVE
First, create a key in redis and set some value in it.
In redis by default 0th database is selected, so now we are moving the generated key in the second database.
127.0.0.1:6379> SET key "PHP" OK 127.0.0.1:6379> MOVE key 1 (integer) 1 127.0.0.1:6379> MOVE key 1 (integer) 0
Example: Redis MOVE another example
127.0.0.1:6379> SET key1 "JavaScript" OK 127.0.0.1:6379> MOVE key1 1 (integer) 1 127.0.0.1:6379> EXISTS key1 (integer) 0 127.0.0.1:6379> SELECT 1 OK 127.0.0.1:6379[1]> GET key1 "JavaScript"
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join