forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add lettuce cluster client when cluster mode enabled --------- Signed-off-by: Andrew Carbonetto <[email protected]>
- Loading branch information
1 parent
30f2f62
commit 05590b0
Showing
10 changed files
with
197 additions
and
79 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
57 changes: 57 additions & 0 deletions
57
java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClusterClient.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,57 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package javababushka.benchmarks.lettuce; | ||
|
||
import io.lettuce.core.RedisFuture; | ||
import io.lettuce.core.RedisURI; | ||
import io.lettuce.core.cluster.RedisClusterClient; | ||
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection; | ||
import io.lettuce.core.cluster.api.async.RedisAdvancedClusterAsyncCommands; | ||
import javababushka.benchmarks.utils.ConnectionSettings; | ||
|
||
public class LettuceAsyncClusterClient extends LettuceAsyncClient { | ||
|
||
private RedisClusterClient clusterClient; | ||
private RedisAdvancedClusterAsyncCommands clusterAsyncCommands; | ||
private StatefulRedisClusterConnection<String, String> clusterConnection; | ||
|
||
@Override | ||
public void connectToRedis() { | ||
connectToRedis(new ConnectionSettings("localhost", 6379, false)); | ||
} | ||
|
||
@Override | ||
public void connectToRedis(ConnectionSettings connectionSettings) { | ||
RedisURI uri = | ||
RedisURI.builder() | ||
.withHost(connectionSettings.host) | ||
.withPort(connectionSettings.port) | ||
.withSsl(connectionSettings.useSsl) | ||
.build(); | ||
clusterClient = RedisClusterClient.create(uri); | ||
clusterConnection = clusterClient.connect(); | ||
clusterAsyncCommands = clusterConnection.async(); | ||
} | ||
|
||
@Override | ||
public RedisFuture<?> asyncSet(String key, String value) { | ||
return clusterAsyncCommands.set(key, value); | ||
} | ||
|
||
@Override | ||
public RedisFuture<String> asyncGet(String key) { | ||
return clusterAsyncCommands.get(key); | ||
} | ||
|
||
@Override | ||
public void closeConnection() { | ||
clusterConnection.close(); | ||
clusterClient.shutdown(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Lettuce Cluster Async"; | ||
} | ||
} |
Oops, something went wrong.