SWAPDB
SWAPDB index1 index2
- Available since:
- Redis Open Source 4.0.0
- Time complexity:
- O(N) where N is the count of clients watching or blocking on keys from both databases.
- ACL categories:
-
@keyspace,@write,@fast,@dangerous, - Compatibility:
- Redis Software and Redis Cloud compatibility
This command swaps two Redis databases, so that immediately all the clients connected to a given database will see the data of the other database, and the other way around.
Required arguments
index1
The index of the first database.
index2
The index of the second database.
Examples
SWAPDB 0 1
This will swap database 0 with database 1. All the clients connected with database 0 will immediately see the new data, exactly like all the clients connected with database 1 will see the data that was formerly of database 0.
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ❌ Standard |
❌ Standard |
Return information
Simple string reply:
OK.