diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/clients/JedisClient.java b/java/benchmarks/src/main/java/javababushka/benchmarks/clients/JedisClient.java new file mode 100644 index 0000000000..d48e0eeeea --- /dev/null +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/clients/JedisClient.java @@ -0,0 +1,58 @@ +package javababushka.benchmarks.clients; + +import javababushka.benchmarks.utils.ConnectionSettings; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; + +/** A jedis client with sync capabilities. See: https://github.com/redis/jedis */ +public class JedisClient implements SyncClient { + + public static final String DEFAULT_HOST = "localhost"; + public static final int DEFAULT_PORT = 6379; + + protected Jedis jedisResource; + + @Override + public void connectToRedis() { + JedisPool pool = new JedisPool(DEFAULT_HOST, DEFAULT_PORT); + jedisResource = pool.getResource(); + } + + @Override + public void closeConnection() { + try { + jedisResource.close(); + } catch (Exception ignored) { + } + } + + @Override + public String getName() { + return "Jedis"; + } + + @Override + public void connectToRedis(ConnectionSettings connectionSettings) { + jedisResource = + new Jedis(connectionSettings.host, connectionSettings.port, connectionSettings.useSsl); + jedisResource.connect(); + } + + public String info() { + return jedisResource.info(); + } + + public String info(String section) { + return jedisResource.info(section); + } + + @Override + public void set(String key, String value) { + jedisResource.set(key, value); + } + + @Override + public String get(String key) { + return jedisResource.get(key); + } +} diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/clients/JedisPseudoAsyncClient.java b/java/benchmarks/src/main/java/javababushka/benchmarks/clients/JedisPseudoAsyncClient.java new file mode 100644 index 0000000000..1aff543c6f --- /dev/null +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/clients/JedisPseudoAsyncClient.java @@ -0,0 +1,42 @@ +package javababushka.benchmarks.clients; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +/** + * A jedis client with pseudo-sync capabilities. Jedis doesn't provide async API + * https://github.com/redis/jedis/issues/241 + * + *
See: https://github.com/redis/jedis
+ */
+public class JedisPseudoAsyncClient extends JedisClient implements AsyncClient {
+ @Override
+ public Future> asyncSet(String key, String value) {
+ return CompletableFuture.runAsync(() -> super.set(key, value));
+ }
+
+ @Override
+ public Future