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 kotlin client created with uniffi interop to java benchmarks.
Signed-off-by: Yury-Fridlyand <[email protected]>
- Loading branch information
1 parent
b89bd23
commit 773b620
Showing
3 changed files
with
62 additions
and
0 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
53 changes: 53 additions & 0 deletions
53
java/benchmarks/src/main/java/javababushka/benchmarks/kotlin/KotlinClient.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,53 @@ | ||
package javababushka.benchmarks.kotlin; | ||
|
||
import babushka.BabushkaClient; | ||
import babushka.BabushkaClientData; | ||
import babushka.BabushkaRedisException; | ||
import javababushka.benchmarks.SyncClient; | ||
import javababushka.benchmarks.utils.ConnectionSettings; | ||
|
||
public class KotlinClient implements SyncClient { | ||
|
||
private BabushkaClient client = new BabushkaClient(); | ||
private BabushkaClientData data = null; | ||
|
||
@Override | ||
public void connectToRedis() { | ||
connectToRedis(new ConnectionSettings("localhost", 6379, false)); | ||
} | ||
|
||
@Override | ||
public void connectToRedis(ConnectionSettings connectionSettings) { | ||
try { | ||
data = client.connect(String.format( | ||
"%s://%s:%d", | ||
connectionSettings.useSsl ? "rediss" : "redis", | ||
connectionSettings.host, | ||
connectionSettings.port)); | ||
} catch (BabushkaRedisException e) { | ||
System.out.printf("Failed to connect: %s%n", e.getMessage()); | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "kotlin"; | ||
} | ||
|
||
@Override | ||
public void set(String key, String value) { | ||
|
||
} | ||
|
||
@Override | ||
public String get(String key) { | ||
try { | ||
return client.get3(data, key); | ||
} catch (BabushkaRedisException e) { | ||
System.out.printf("failed to get3: %s%n", e.getMessage()); | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
} |