Skip to content

Commit

Permalink
Revert ExampleApp
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed May 10, 2024
1 parent eeed31c commit ab86d4b
Showing 1 changed file with 4 additions and 61 deletions.
65 changes: 4 additions & 61 deletions java/examples/src/main/java/glide/examples/ExamplesApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,67 +32,10 @@ private static void runGlideExamples() {
try {
RedisClient client = RedisClient.CreateClient(config).get();

String key1 = "{key1}-" + UUID.randomUUID();
String key2 = "{key2}-" + UUID.randomUUID();
String field1 = "f1_";
String field2 = "f2_";
String field3 = "f3_";

Map<String, String> timestamp_1_1_map = new LinkedHashMap<>();
timestamp_1_1_map.put(field1, field1 + "1");
timestamp_1_1_map.put(field3, field3 + "1");
String timestamp_1_1 =
client.xadd(key1, timestamp_1_1_map, StreamAddOptions.builder().id("1-1").build()).get();

String timestamp_2_1 =
client
.xadd(
key2, Map.of(field2, field2 + "1"), StreamAddOptions.builder().id("2-1").build())
.get();

String timestamp_1_2 =
client
.xadd(
key1, Map.of(field1, field1 + "2"), StreamAddOptions.builder().id("1-2").build())
.get();

String timestamp_2_2 =
client
.xadd(
key2, Map.of(field2, field2 + "2"), StreamAddOptions.builder().id("2-2").build())
.get();

// setup third entries in streams key1 and key2
Map<String, String> timestamp_1_3_map = new LinkedHashMap<>();
timestamp_1_3_map.put(field1, field1 + "3");
timestamp_1_3_map.put(field3, field3 + "3");

String timestamp_1_3 =
client.xadd(key1, timestamp_1_3_map, StreamAddOptions.builder().id("1-3").build()).get();

String timestamp_2_3 =
client
.xadd(
key2, Map.of(field2, field2 + "3"), StreamAddOptions.builder().id("2-3").build())
.get();

StreamReadOptions blockOption = StreamReadOptions.builder().block(1L).build();

Map<String, Map<String, Map<String, String>>> result =
client.xread(Map.of(key1, timestamp_1_1, key2, timestamp_2_1), blockOption).get();

for (var keyentry : result.entrySet()) {
for (var streamEntry : keyentry.getValue().entrySet()) {
for (var fieldEntry : streamEntry.getValue().entrySet()) {
System.out.printf(
"Key: %s; stream id: %s; field: %s; value: %s\n",
keyentry.getKey(),
streamEntry.getKey(),
fieldEntry.getKey(),
fieldEntry.getValue());
}
}
}
System.out.println("PING: " + client.ping().get());
System.out.println("PING(found you): " + client.ping("found you").get());
System.out.println("SET(apples, oranges): " + client.set("apples", "oranges").get());
System.out.println("GET(apples): " + client.get("apples").get());

} catch (ExecutionException | InterruptedException e) {
System.out.println("Glide example failed with an exception: ");
Expand Down

0 comments on commit ab86d4b

Please sign in to comment.