Skip to content

Commit

Permalink
Merge pull request #48 from cchacin/master
Browse files Browse the repository at this point in the history
Use interfaces to easy DI and Unit testing
  • Loading branch information
Nikita Koksharov committed Jul 29, 2014
2 parents d9b19ff + 0f99ff0 commit 050fe84
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/main/java/org/redisson/Redisson.java
Expand Up @@ -15,29 +15,16 @@
*/
package org.redisson;

import com.lambdaworks.redis.RedisAsyncConnection;
import io.netty.util.concurrent.Future;

import java.util.UUID;

import org.redisson.async.ResultOperation;
import org.redisson.connection.ConnectionManager;
import org.redisson.connection.MasterSlaveConnectionManager;
import org.redisson.connection.SentinelConnectionManager;
import org.redisson.connection.SingleConnectionManager;
import org.redisson.core.RAtomicLong;
import org.redisson.core.RBucket;
import org.redisson.core.RCountDownLatch;
import org.redisson.core.RDeque;
import org.redisson.core.RHyperLogLog;
import org.redisson.core.RList;
import org.redisson.core.RLock;
import org.redisson.core.RMap;
import org.redisson.core.RQueue;
import org.redisson.core.RSet;
import org.redisson.core.RSortedSet;
import org.redisson.core.RTopic;
import org.redisson.core.*;

import com.lambdaworks.redis.RedisAsyncConnection;
import java.util.UUID;

/**
* Main infrastructure class allows to get access
Expand All @@ -46,7 +33,7 @@
* @author Nikita Koksharov
*
*/
public class Redisson {
public class Redisson implements RedissonClient {

private final ConnectionManager connectionManager;
private final Config config;
Expand Down Expand Up @@ -94,6 +81,7 @@ public static Redisson create(Config config) {
* @param name of object
* @return
*/
@Override
public <V> RBucket<V> getBucket(String name) {
return new RedissonBucket<V>(connectionManager, name);
}
Expand All @@ -104,6 +92,7 @@ public <V> RBucket<V> getBucket(String name) {
* @param name of object
* @return
*/
@Override
public <V> RHyperLogLog<V> getHyperLogLog(String name) {
return new RedissonHyperLogLog<V>(connectionManager, name);
}
Expand All @@ -114,6 +103,7 @@ public <V> RHyperLogLog<V> getHyperLogLog(String name) {
* @param name of the distributed list
* @return distributed list
*/
@Override
public <V> RList<V> getList(String name) {
return new RedissonList<V>(connectionManager, name);
}
Expand All @@ -124,6 +114,7 @@ public <V> RList<V> getList(String name) {
* @param name of the distributed map
* @return distributed map
*/
@Override
public <K, V> RMap<K, V> getMap(String name) {
return new RedissonMap<K, V>(connectionManager, name);
}
Expand All @@ -134,6 +125,7 @@ public <K, V> RMap<K, V> getMap(String name) {
* @param name of the distributed lock
* @return distributed lock
*/
@Override
public RLock getLock(String name) {
return new RedissonLock(connectionManager, name, id);
}
Expand All @@ -144,6 +136,7 @@ public RLock getLock(String name) {
* @param name of the distributed set
* @return distributed set
*/
@Override
public <V> RSet<V> getSet(String name) {
return new RedissonSet<V>(connectionManager, name);
}
Expand All @@ -154,6 +147,7 @@ public <V> RSet<V> getSet(String name) {
* @param name of the distributed set
* @return distributed set
*/
@Override
public <V> RSortedSet<V> getSortedSet(String name) {
return new RedissonSortedSet<V>(connectionManager, name);
}
Expand All @@ -164,6 +158,7 @@ public <V> RSortedSet<V> getSortedSet(String name) {
* @param name of the distributed topic
* @return distributed topic
*/
@Override
public <M> RTopic<M> getTopic(String name) {
return new RedissonTopic<M>(connectionManager, name);
}
Expand All @@ -174,6 +169,7 @@ public <M> RTopic<M> getTopic(String name) {
* @param name of the distributed queue
* @return distributed queue
*/
@Override
public <V> RQueue<V> getQueue(String name) {
return new RedissonQueue<V>(connectionManager, name);
}
Expand All @@ -184,6 +180,7 @@ public <V> RQueue<V> getQueue(String name) {
* @param name of the distributed queue
* @return distributed queue
*/
@Override
public <V> RDeque<V> getDeque(String name) {
return new RedissonDeque<V>(connectionManager, name);
}
Expand All @@ -194,6 +191,7 @@ public <V> RDeque<V> getDeque(String name) {
* @param name of the distributed "atomic long"
* @return distributed "atomic long"
*/
@Override
public RAtomicLong getAtomicLong(String name) {
return new RedissonAtomicLong(connectionManager, name);
}
Expand All @@ -204,6 +202,7 @@ public RAtomicLong getAtomicLong(String name) {
* @param name of the distributed "count down latch"
* @return distributed "count down latch"
*/
@Override
public RCountDownLatch getCountDownLatch(String name) {
return new RedissonCountDownLatch(connectionManager, name, id);
}
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/org/redisson/RedissonClient.java
@@ -0,0 +1,29 @@
package org.redisson;

import org.redisson.core.*;

public interface RedissonClient {
<V> RBucket<V> getBucket(String name);

<V> RHyperLogLog<V> getHyperLogLog(String name);

<V> RList<V> getList(String name);

<K, V> RMap<K, V> getMap(String name);

RLock getLock(String name);

<V> RSet<V> getSet(String name);

<V> RSortedSet<V> getSortedSet(String name);

<M> RTopic<M> getTopic(String name);

<V> RQueue<V> getQueue(String name);

<V> RDeque<V> getDeque(String name);

RAtomicLong getAtomicLong(String name);

RCountDownLatch getCountDownLatch(String name);
}

0 comments on commit 050fe84

Please sign in to comment.