2
2
package glide .examples ;
3
3
4
4
import glide .api .RedisClient ;
5
- import glide .api .RedisClusterClient ;
6
- import glide .examples .clients .GlideClient ;
7
- import glide .examples .clients .GlideClusterClient ;
5
+ import glide .api .models .configuration .NodeAddress ;
6
+ import glide .api .models .configuration .RedisClientConfiguration ;
8
7
import java .util .concurrent .ExecutionException ;
9
8
10
9
public class ExamplesApp {
11
10
12
11
// main application entrypoint
13
12
public static void main (String [] args ) {
14
13
runGlideExamples ();
15
-
16
- // uncomment to test against a Redis instance with cluster-mode enabled
17
- // runGlideClusterModeExamples();
18
14
}
19
15
20
16
private static void runGlideExamples () {
21
- ConnectionSettings settings = new ConnectionSettings ("localhost" , 6379 , false , false );
17
+ String host = "localhost" ;
18
+ Integer port = 6379 ;
19
+ boolean useSsl = false ;
20
+
21
+ RedisClientConfiguration config =
22
+ RedisClientConfiguration .builder ()
23
+ .address (NodeAddress .builder ().host (host ).port (port ).build ())
24
+ .useTLS (useSsl )
25
+ .build ();
22
26
23
27
try {
24
- RedisClient client = GlideClient . connectToGlide ( settings );
28
+ RedisClient client = RedisClient . CreateClient ( config ). get ( );
25
29
26
30
System .out .println ("Glide PING: " + client .ping ().get ());
27
31
System .out .println ("Glide PING: " + client .ping ("found you" ).get ());
@@ -31,37 +35,4 @@ private static void runGlideExamples() {
31
35
e .printStackTrace ();
32
36
}
33
37
}
34
-
35
- private static void runGlideClusterModeExamples () {
36
- ConnectionSettings settings = new ConnectionSettings ("localhost" , 8000 , false , true );
37
-
38
- try {
39
- RedisClusterClient client = GlideClusterClient .connectToGlide (settings );
40
-
41
- System .out .println ("Glide PING: " );
42
- System .out .println (">>>> " + client .ping ().get ());
43
-
44
- System .out .println ("Glide PING(msg): " );
45
- System .out .println (">>>> " + client .ping ("msg" ).get ());
46
-
47
- } catch (ExecutionException | InterruptedException e ) {
48
- System .out .println ("Glide example failed with an exception: " );
49
- e .printStackTrace ();
50
- }
51
- }
52
-
53
- /** Redis-client settings */
54
- public static class ConnectionSettings {
55
- public final String host ;
56
- public final int port ;
57
- public final boolean useSsl ;
58
- public final boolean clusterMode ;
59
-
60
- public ConnectionSettings (String host , int port , boolean useSsl , boolean clusterMode ) {
61
- this .host = host ;
62
- this .port = port ;
63
- this .useSsl = useSsl ;
64
- this .clusterMode = clusterMode ;
65
- }
66
- }
67
38
}
0 commit comments