-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pipelining from UnifiedJedis (#3221)
- Loading branch information
Showing
16 changed files
with
177 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 24 additions & 29 deletions
53
src/test/java/redis/clients/jedis/commands/unified/pooled/PooledHashesCommandsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,24 @@ | ||
//package redis.clients.jedis.commands.unified.cluster; | ||
// | ||
//import org.junit.AfterClass; | ||
//import org.junit.Before; | ||
//import org.junit.BeforeClass; | ||
//import redis.clients.jedis.commands.unified.HashesCommandsTestBase; | ||
// | ||
//public class ClusterHashesCommandsTest extends HashesCommandsTestBase { | ||
// | ||
// @BeforeClass | ||
// public static void prepare() throws InterruptedException { | ||
// jedis = ClusterCommandsTestHelper.initAndGetCluster(); | ||
// } | ||
// | ||
// @AfterClass | ||
// public static void closeCluster() { | ||
// jedis.close(); | ||
// } | ||
// | ||
// @AfterClass | ||
// public static void resetCluster() { | ||
// ClusterCommandsTestHelper.tearClusterDown(); | ||
// } | ||
// | ||
// @Before | ||
// public void setUp() { | ||
// ClusterCommandsTestHelper.clearClusterData(); | ||
// } | ||
//} | ||
package redis.clients.jedis.commands.unified.pooled; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import redis.clients.jedis.commands.unified.HashesCommandsTestBase; | ||
|
||
public class PooledHashesCommandsTest extends HashesCommandsTestBase { | ||
|
||
@BeforeClass | ||
public static void prepare() throws InterruptedException { | ||
jedis = PooledCommandsTestHelper.getPooled(); | ||
} | ||
|
||
@AfterClass | ||
public static void cleanUp() { | ||
jedis.close(); | ||
} | ||
|
||
@Before | ||
public void setUp() { | ||
PooledCommandsTestHelper.clearData(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/test/java/redis/clients/jedis/commands/unified/pooled/PooledPipelinedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package redis.clients.jedis.commands.unified.pooled; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import redis.clients.jedis.JedisPooled; | ||
import redis.clients.jedis.Pipeline; | ||
import redis.clients.jedis.Response; | ||
|
||
import redis.clients.jedis.commands.unified.UnifiedJedisCommandsTestBase; | ||
|
||
public class PooledPipelinedTest extends UnifiedJedisCommandsTestBase { | ||
|
||
protected Pipeline pipeline; | ||
|
||
@BeforeClass | ||
public static void prepare() throws InterruptedException { | ||
jedis = PooledCommandsTestHelper.getPooled(); | ||
} | ||
|
||
@AfterClass | ||
public static void cleanUp() { | ||
jedis.close(); | ||
} | ||
|
||
@Before | ||
public void setUp() { | ||
PooledCommandsTestHelper.clearData(); | ||
pipeline = ((JedisPooled) jedis).pipelined(); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
pipeline.close(); | ||
} | ||
|
||
@Test | ||
public void simple() { | ||
final int count = 10; | ||
int totalCount = 0; | ||
for (int i = 0; i < count; i++) { | ||
jedis.set("foo" + i, "bar" + i); | ||
} | ||
totalCount += count; | ||
for (int i = 0; i < count; i++) { | ||
jedis.rpush("foobar" + i, "foo" + i, "bar" + i); | ||
} | ||
totalCount += count; | ||
|
||
List<Response<?>> responses = new ArrayList<>(totalCount); | ||
List<Object> expected = new ArrayList<>(totalCount); | ||
for (int i = 0; i < count; i++) { | ||
responses.add(pipeline.get("foo" + i)); | ||
expected.add("bar" + i); | ||
} | ||
for (int i = 0; i < count; i++) { | ||
responses.add(pipeline.lrange("foobar" + i, 0, -1)); | ||
expected.add(Arrays.asList("foo" + i, "bar" + i)); | ||
} | ||
pipeline.sync(); | ||
|
||
for (int i = 0; i < totalCount; i++) { | ||
assertEquals(expected.get(i), responses.get(i).get()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters