Skip to main content

SWAPDB

Syntax

SWAPDB index1 index2

Module

connection

Categories

connection dangerous keyspace slow

Description

This command swaps two 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. If either one of the databases does not exist, it will be created.

Examples

Swap the databases with indexes 1 and 2:

vault, err := echovault.NewEchoVault()
if err != nil {
log.Fatal(err)
}
err := vault.SwapDBs(1, 2)

The method above only switches the databases for the currently active TCP connections. To switch the database for the embeded instance, use the SelectDB method.