code cleanup

pull/337/head
Nikita 9 years ago
parent 51c8664b11
commit 914892f534

@ -18,7 +18,6 @@ package org.redisson;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import org.redisson.api.RAtomicLongReactive;
import org.redisson.api.RBatchReactive;
@ -47,6 +46,9 @@ import org.redisson.connection.ElasticacheConnectionManager;
import org.redisson.connection.MasterSlaveConnectionManager;
import org.redisson.connection.SentinelConnectionManager;
import org.redisson.connection.SingleConnectionManager;
import org.redisson.core.ClusterNode;
import org.redisson.core.Node;
import org.redisson.core.NodesGroup;
import org.redisson.reactive.RedissonAtomicLongReactive;
import org.redisson.reactive.RedissonBatchReactive;
import org.redisson.reactive.RedissonBitSetReactive;
@ -80,8 +82,6 @@ public class RedissonReactive implements RedissonReactiveClient {
private final ConnectionManager connectionManager;
private final Config config;
private final UUID id = UUID.randomUUID();
RedissonReactive(Config config) {
this.config = config;
Config configCopy = new Config(config);
@ -262,23 +262,28 @@ public class RedissonReactive implements RedissonReactiveClient {
return new RedissonKeysReactive(commandExecutor);
}
@Override
public Config getConfig() {
return config;
}
@Override
public void shutdown() {
connectionManager.shutdown();
public NodesGroup<Node> getNodesGroup() {
return new RedisNodes<Node>(connectionManager);
}
@Override
public void flushdb() {
commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHDB));
public NodesGroup<ClusterNode> getClusterNodesGroup() {
if (!config.isClusterConfig()) {
throw new IllegalStateException("Redisson not in cluster mode!");
}
return new RedisNodes<ClusterNode>(connectionManager);
}
@Override
public void flushall() {
commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHALL));
public void shutdown() {
connectionManager.shutdown();
}
}

@ -19,17 +19,38 @@ import java.util.Collection;
import org.reactivestreams.Publisher;
import io.netty.util.concurrent.Future;
public interface RKeysReactive {
/**
* Load keys in incrementally iterate mode.
*
* Uses <code>SCAN</code> Redis command.
*
* @param pattern
* @return
*/
Publisher<String> getKeys();
/**
* Find keys by pattern and load it in incrementally iterate mode.
*
* Uses <code>SCAN</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
* @return
*/
Publisher<String> getKeysByPattern(String pattern);
/**
* Get hash slot identifier for key in mode.
* Available for cluster nodes only
* Get hash slot identifier for key.
* Available for cluster nodes only.
*
* Uses <code>KEYSLOT</code> Redis command.
*
* @param key
* @return
@ -37,7 +58,9 @@ public interface RKeysReactive {
Publisher<Integer> getSlot(String key);
/**
* Find keys by key search pattern by one Redis call
* 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
@ -50,14 +73,18 @@ public interface RKeysReactive {
Publisher<Collection<String>> findKeysByPattern(String pattern);
/**
* Get random key in mode
* Get random key
*
* Uses <code>RANDOM_KEY</code> Redis command.
*
* @return
*/
Publisher<String> randomKey();
/**
* Delete multiple objects by a key pattern in mode
* Delete multiple objects by a key pattern.
*
* Uses Lua script.
*
* Supported glob-style patterns:
* h?llo subscribes to hello, hallo and hxllo
@ -70,11 +97,29 @@ public interface RKeysReactive {
Publisher<Long> deleteByPattern(String pattern);
/**
* Delete multiple objects by name in mode
* Delete multiple objects by name.
*
* Uses <code>DEL</code> Redis command.
*
* @param keys - object names
* @return
*/
Publisher<Long> delete(String ... keys);
/**
* Delete all the keys of the currently selected database
*
* Uses <code>FLUSHDB</code> Redis command.
*
*/
Publisher<Void> flushdb();
/**
* Delete all the keys of all the existing databases
*
* Uses <code>FLUSHALL</code> Redis command.
*
*/
Publisher<Void> flushall();
}

@ -19,6 +19,9 @@ import java.util.List;
import org.redisson.Config;
import org.redisson.client.codec.Codec;
import org.redisson.core.ClusterNode;
import org.redisson.core.Node;
import org.redisson.core.NodesGroup;
public interface RedissonReactiveClient {
@ -201,28 +204,18 @@ public interface RedissonReactiveClient {
*/
Config getConfig();
// /**
// * Get Redis nodes group for server operations
// *
// * @return
// */
// NodesGroup<Node> getNodesGroup();
//
// /**
// * Get Redis cluster nodes group for server operations
// *
// * @return
// */
// NodesGroup<ClusterNode> getClusterNodesGroup();
//
/**
* Delete all the keys of the currently selected database
* Get Redis nodes group for server operations
*
* @return
*/
void flushdb();
NodesGroup<Node> getNodesGroup();
/**
* Delete all the keys of all the existing databases
* Get Redis cluster nodes group for server operations
*
* @return
*/
void flushall();
NodesGroup<ClusterNode> getClusterNodesGroup();
}

@ -151,17 +151,6 @@ public class RedissonKeysReactive implements RKeysReactive {
};
}
/**
* Find keys by key search pattern by one Redis call
*
* 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
* @return
*/
@Override
public Publisher<Collection<String>> findKeysByPattern(String pattern) {
return commandExecutor.readAllReactive(RedisCommands.KEYS, pattern);
@ -172,17 +161,6 @@ public class RedissonKeysReactive implements RKeysReactive {
return commandExecutor.readRandomReactive(RedisCommands.RANDOM_KEY);
}
/**
* Delete multiple objects by a key pattern
*
* 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
* @return
*/
@Override
public Publisher<Long> deleteByPattern(String pattern) {
return commandExecutor.evalWriteAllReactive(RedisCommands.EVAL_LONG, new SlotCallback<Long, Long>() {
@ -204,12 +182,6 @@ public class RedissonKeysReactive implements RKeysReactive {
+ "return n;",Collections.emptyList(), pattern);
}
/**
* Delete multiple objects by name
*
* @param keys - object names
* @return
*/
@Override
public Publisher<Long> delete(String ... keys) {
return commandExecutor.writeAllReactive(RedisCommands.DEL, new SlotCallback<Long, Long>() {
@ -226,5 +198,14 @@ public class RedissonKeysReactive implements RKeysReactive {
}, (Object[])keys);
}
@Override
public Publisher<Void> flushdb() {
return commandExecutor.writeAllReactive(RedisCommands.FLUSHDB);
}
@Override
public Publisher<Void> flushall() {
return commandExecutor.writeAllReactive(RedisCommands.FLUSHALL);
}
}

Loading…
Cancel
Save