From bf64e3a95d4bc67f203dc72157e53c97031c0439 Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 24 Jul 2015 15:57:59 +0300 Subject: [PATCH] new methods added to RedissonClient interface --- src/main/java/org/redisson/Redisson.java | 25 ++++- .../java/org/redisson/RedissonClient.java | 95 +++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/redisson/Redisson.java b/src/main/java/org/redisson/Redisson.java index 8ba37b9f1..5d07edd4c 100755 --- a/src/main/java/org/redisson/Redisson.java +++ b/src/main/java/org/redisson/Redisson.java @@ -296,6 +296,7 @@ public class Redisson implements RedissonClient { /** * Shuts down Redisson instance NOT Redis server */ + @Override public void shutdown() { connectionManager.shutdown(); } @@ -307,6 +308,7 @@ public class Redisson implements RedissonClient { * * @return Config object */ + @Override public Config getConfig() { return config; } @@ -322,6 +324,7 @@ public class Redisson implements RedissonClient { * @param pattern * @return */ + @Override public Queue findKeysByPattern(String pattern) { return commandExecutor.get(findKeysByPatternAsync(pattern)); } @@ -337,6 +340,7 @@ public class Redisson implements RedissonClient { * @param pattern * @return */ + @Override public Future> findKeysByPatternAsync(String pattern) { return commandExecutor.readAllAsync(RedisCommands.KEYS, pattern); } @@ -352,6 +356,7 @@ public class Redisson implements RedissonClient { * @param pattern * @return */ + @Override public long deleteByPattern(String pattern) { return commandExecutor.get(deleteByPatternAsync(pattern)); } @@ -367,6 +372,7 @@ public class Redisson implements RedissonClient { * @param pattern * @return */ + @Override public Future deleteByPatternAsync(String pattern) { return commandExecutor.evalWriteAllAsync(RedisCommands.EVAL_INTEGER, new SlotCallback() { AtomicLong results = new AtomicLong(); @@ -393,6 +399,7 @@ public class Redisson implements RedissonClient { * @param keys - object names * @return */ + @Override public long delete(String ... keys) { return commandExecutor.get(deleteAsync(keys)); } @@ -403,6 +410,7 @@ public class Redisson implements RedissonClient { * @param keys - object names * @return */ + @Override public Future deleteAsync(String ... keys) { return commandExecutor.writeAllAsync(RedisCommands.DEL, new SlotCallback() { AtomicLong results = new AtomicLong(); @@ -418,15 +426,30 @@ public class Redisson implements RedissonClient { }, (Object[])keys); } + /** + * Delete all the keys of the currently selected database + */ + @Override public void flushdb() { commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHDB)); } + /** + * Delete all the keys of all the existing databases + */ + @Override public void flushall() { commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHALL)); } - + /** + * Return batch object which executes group of + * command in pipeline. + * + * See http://redis.io/topics/pipelining + * + * @return + */ @Override public RBatch createBatch() { return new RedissonBatch(connectionManager); diff --git a/src/main/java/org/redisson/RedissonClient.java b/src/main/java/org/redisson/RedissonClient.java index da1a501e1..43f12bdaf 100755 --- a/src/main/java/org/redisson/RedissonClient.java +++ b/src/main/java/org/redisson/RedissonClient.java @@ -17,7 +17,10 @@ package org.redisson; import org.redisson.core.*; +import io.netty.util.concurrent.Future; + import java.util.List; +import java.util.Queue; public interface RedissonClient { @@ -160,4 +163,96 @@ public interface RedissonClient { */ RBatch createBatch(); + /** + * Shuts down Redisson instance NOT Redis server + */ + void shutdown(); + + /** + * Allows to get configuration provided + * during Redisson instance creation. Further changes on + * this object not affect Redisson instance. + * + * @return Config object + */ + Config getConfig(); + + /** + * Find keys by key search 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 + */ + Queue findKeysByPattern(String pattern); + + /** + * Find keys by key search pattern in async mode + * + * 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 + */ + Future> findKeysByPatternAsync(String pattern); + + /** + * 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 + */ + long deleteByPattern(String pattern); + + /** + * Delete multiple objects by a key pattern in async mode + * + * 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 + */ + Future deleteByPatternAsync(String pattern); + + /** + * Delete multiple objects by name + * + * @param keys - object names + * @return + */ + long delete(String ... keys); + + /** + * Delete multiple objects by name in async mode + * + * @param keys - object names + * @return + */ + Future deleteAsync(String ... keys); + + /** + * Delete all the keys of the currently selected database + */ + void flushdb(); + + /** + * Delete all the keys of all the existing databases + */ + void flushall(); + }