Skip to content

Commit

Permalink
Updates code with 5.0.0-beta2 jedis.
Browse files Browse the repository at this point in the history
  • Loading branch information
viragtripathi committed Jun 18, 2023
1 parent ca05786 commit d07f276
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutE
at redis.clients.jedis.executors.CircuitBreakerCommandExecutor.executeCommand(CircuitBreakerCommandExecutor.java:55)
at redis.clients.jedis.UnifiedJedis.executeCommand(UnifiedJedis.java:180)
at redis.clients.jedis.UnifiedJedis.get(UnifiedJedis.java:602)
at com.redis.benchmark.utils.Util.createOneMillionOfKeys(Util.java:15)
at createOneMillionStringKeysKeys(Util.java:15)
at com.redis.benchmark.RedisBenchmark.setup(RedisBenchmark.java:25)
at com.redis.benchmark.jmh_generated.RedisBenchmark_jedisSimpleGet_jmhTest._jmh_tryInit_f_redisbenchmark0_0(RedisBenchmark_jedisSimpleGet_jmhTest.java:338)
at com.redis.benchmark.jmh_generated.RedisBenchmark_jedisSimpleGet_jmhTest.jedisSimpleGet_Throughput(RedisBenchmark_jedisSimpleGet_jmhTest.java:71)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.36</jmh.version>
<jedis.version>5.0.0-SNAPSHOT</jedis.version>
<jedis.version>5.0.0-beta2</jedis.version>
<jreleaser.version>1.3.1</jreleaser.version>
<resilience4j.version>1.7.1</resilience4j.version>
<slf4j.version>1.7.36</slf4j.version>
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/com/redis/benchmark/RedisBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
import com.redis.benchmark.utils.BenchmarkConfiguration;
import com.redis.benchmark.utils.JedisConnectionManagement;
import com.redis.benchmark.utils.Util;
import org.openjdk.jmh.annotations.*;
import redis.clients.jedis.commands.JedisCommands;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.TearDown;
import redis.clients.jedis.UnifiedJedis;

@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
@Warmup(iterations = 1)
Expand All @@ -14,15 +25,15 @@
@Measurement(iterations = 1, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class RedisBenchmark {
private static JedisCommands jedisCommands;
private static UnifiedJedis jedisCommands;
private static Integer jedisGetCount = 0;
private static Integer jedisSetCount = 0;

@Setup(Level.Trial)
public void setup() {
System.out.println("\n------------------- Setup");

Util.createOneMillionOfKeys();
Util.createOneMillionStringKeys();

jedisCommands = JedisConnectionManagement.getCommands();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.redis.benchmark.utils;

import java.io.File;
import java.nio.file.Path;
import java.util.Set;
import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisClientConfig;
import redis.clients.jedis.MultiClusterClientConfig.ClusterConfig;
import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.commands.JedisCommands;
import redis.clients.jedis.MultiClusterClientConfig;
import redis.clients.jedis.providers.MultiClusterPooledConnectionProvider;

import java.io.File;
import java.nio.file.Path;
import java.util.Set;

public final class JedisConnectionManagement {
private static final JedisConnectionManagement connectionManagement = new JedisConnectionManagement();
private static Boolean connectionCreated = false;
Expand Down Expand Up @@ -70,7 +68,7 @@ private void createJedisConnection() {
}
}

public static JedisCommands getCommands() {
public static UnifiedJedis getCommands() {
if (!connectionCreated) {
connectionManagement.createJedisConnection();
connectionCreated = Boolean.TRUE;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/redis/benchmark/utils/Util.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redis.benchmark.utils;

import redis.clients.jedis.commands.JedisCommands;
import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.exceptions.JedisConnectionException;

public final class Util {
Expand All @@ -10,8 +10,8 @@ public final class Util {
private Util() {
}

public static void createOneMillionOfKeys() {
JedisCommands commands = JedisConnectionManagement.getCommands();
public static void createOneMillionStringKeys() {
UnifiedJedis commands = JedisConnectionManagement.getCommands();
String keysCreated = commands.get(BenchmarkKeysCreated);
if (keysCreated != null && keysCreated.equals("y")) {
return;
Expand Down

0 comments on commit d07f276

Please sign in to comment.