提交 3b9ddc6e 编写于 作者: N Nikita Koksharov

Feature - add SWAPDB command support #2606

上级 4eb63c8c
......@@ -519,4 +519,13 @@ public class RedissonKeys implements RKeys {
return toStream(getKeys(count).iterator());
}
@Override
public void swapdb(int db1, int db2) {
commandExecutor.get(swapdbAsync(db1, db2));
}
@Override
public RFuture<Void> swapdbAsync(int db1, int db2) {
return commandExecutor.writeAsync(null, RedisCommands.SWAPDB, db1, db2);
}
}
......@@ -311,6 +311,11 @@ public interface RKeys extends RKeysAsync {
*/
long count();
/**
* Swap two databases.
*/
void swapdb(int db1, int db2);
/**
* Delete all keys of currently selected database
*/
......
......@@ -206,14 +206,25 @@ public interface RKeysAsync {
*/
RFuture<Long> countAsync();
/**
* Swap two databases.
* <p>
* Requires Redis 4.0+
*
* @return void
*/
RFuture<Void> swapdbAsync(int db1, int db2);
/**
* Delete all keys of currently selected database
*
* @return void
*/
RFuture<Void> flushdbAsync();
/**
* Delete all keys of all existing databases
*
* @return void
*/
RFuture<Void> flushallAsync();
......
......@@ -15,12 +15,11 @@
*/
package org.redisson.api;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.concurrent.TimeUnit;
/**
*
* @author Nikita Koksharov
......@@ -207,21 +206,6 @@ public interface RKeysReactive {
*/
Mono<Integer> getSlot(String key);
/**
* Find keys by key search pattern by one Redis call.
*
* Uses <code>KEYS</code> Redis command.
*
* Supported glob-style patterns:
* h?llo subscribes to hello, hallo and hxllo
* h*llo subscribes to hllo and heeeello
* h[ae]llo subscribes to hello and hallo, but not hillo
*
* @param pattern - match pattern
* @return collection of keys
*/
Mono<Collection<String>> findKeysByPattern(String pattern);
/**
* Get random key
*
......@@ -283,6 +267,15 @@ public interface RKeysReactive {
*/
Mono<Void> flushdb();
/**
* Swap two databases.
* <p>
* Requires Redis 4.0+
*
* @return void
*/
Mono<Void> swapdb(int db1, int db2);
/**
* Delete all the keys of all the existing databases
*
......@@ -292,4 +285,24 @@ public interface RKeysReactive {
*/
Mono<Void> flushall();
/**
* Delete all keys of currently selected database
* in background without blocking server.
* <p>
* Requires Redis 4.0+
*
* @return void
*/
Mono<Void> flushdbParallel();
/**
* Delete all keys of all existing databases
* in background without blocking server.
* <p>
* Requires Redis 4.0+
*
* @return void
*/
Mono<Void> flushallParallel();
}
......@@ -269,6 +269,15 @@ public interface RKeysRx {
*/
Completable flushdb();
/**
* Swap two databases.
* <p>
* Requires Redis 4.0+
*
* @return void
*/
Completable swapdb(int db1, int db2);
/**
* Delete all the keys of all the existing databases
*
......@@ -278,4 +287,24 @@ public interface RKeysRx {
*/
Completable flushall();
/**
* Delete all keys of currently selected database
* in background without blocking server.
* <p>
* Requires Redis 4.0+
*
* @return void
*/
Completable flushdbParallel();
/**
* Delete all keys of all existing databases
* in background without blocking server.
* <p>
* Requires Redis 4.0+
*
* @return void
*/
Completable flushallParallel();
}
......@@ -275,6 +275,7 @@ public interface RedisCommands {
RedisStrictCommand<Void> CLIENT_SETNAME = new RedisStrictCommand<Void>("CLIENT", "SETNAME", new VoidReplayConvertor());
RedisStrictCommand<String> CLIENT_GETNAME = new RedisStrictCommand<String>("CLIENT", "GETNAME", new StringDataDecoder());
RedisStrictCommand<Void> FLUSHDB = new RedisStrictCommand<Void>("FLUSHDB", new VoidReplayConvertor());
RedisStrictCommand<Void> SWAPDB = new RedisStrictCommand<Void>("SWAPDB", new VoidReplayConvertor());
RedisStrictCommand<Void> FLUSHALL = new RedisStrictCommand<Void>("FLUSHALL", new VoidReplayConvertor());
RedisStrictCommand<Void> SAVE = new RedisStrictCommand<Void>("SAVE", new VoidReplayConvertor());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册