@@ -54,36 +54,26 @@ To build from source, see the instructions on the [Lettuce source code GitHub re
5454
5555## Connect and test
5656
57- Connect to a local server using the following code. This example
58- also stores and retrieves a simple string value to test the connection
59- and closes the connection after use.
57+ Connect to a local server using the following code. First, import
58+ the required classes.
6059
61- ``` java
62- import io.lettuce.core.* ;
63- import io.lettuce.core.api.StatefulRedisConnection ;
64- import io.lettuce.core.api.sync.RedisCommands ;
60+ {{< clients-example set="landing" step="import" lang_filter="Lettuce-Sync" >}}
61+ {{< /clients-example >}}
6562
66- public class ConnectBasicTest {
63+ Use the following code to connect to the server.
6764
68- public void connectBasic () {
69- RedisURI uri = RedisURI . Builder
70- .redis(" localhost" , 6379 )
71- .build();
65+ {{< clients-example set="landing" step="connect" lang_filter="Lettuce-Sync" >}}
66+ {{< /clients-example >}}
7267
73- RedisClient client = RedisClient . create(uri);
74- StatefulRedisConnection<String , String > connection = client. connect();
75- RedisCommands<String , String > commands = connection. sync();
68+ Test the connection by storing and retrieving a simple string.
7669
77- commands. set(" foo" , " bar" );
78- String result = commands. get(" foo" );
79- System . out. println(result); // >>> bar
70+ {{< clients-example set="landing" step="set_get_string" lang_filter="Lettuce-Sync" >}}
71+ {{< /clients-example >}}
8072
81- connection . close();
73+ Close the connection when you're done.
8274
83- client. shutdown();
84- }
85- }
86- ```
75+ {{< clients-example set="landing" step="close" lang_filter="Lettuce-Sync" >}}
76+ {{< /clients-example >}}
8777
8878## More information
8979
0 commit comments