Skip to content

Commit 7aad5c7

Browse files
DOC-5963 prepared Lettuce landing page for notebook
1 parent 041b328 commit 7aad5c7

File tree

2 files changed

+47
-23
lines changed

2 files changed

+47
-23
lines changed

content/develop/clients/lettuce/_index.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// EXAMPLE: landing
2+
// BINDER_ID lettuce-landing
3+
// STEP_START import
4+
import io.lettuce.core.*;
5+
import io.lettuce.core.api.StatefulRedisConnection;
6+
import io.lettuce.core.api.sync.RedisCommands;
7+
// STEP_END
8+
9+
10+
public class ConnectBasicTest {
11+
12+
public void connectBasic() {
13+
// STEP_START connect
14+
RedisURI uri = RedisURI.Builder
15+
.redis("localhost", 6379)
16+
.build();
17+
18+
RedisClient client = RedisClient.create(uri);
19+
StatefulRedisConnection<String, String> connection = client.connect();
20+
RedisCommands<String, String> commands = connection.sync();
21+
// STEP_END
22+
23+
// STEP_START set_get_string
24+
commands.set("foo", "bar");
25+
String result = commands.get("foo");
26+
System.out.println(result); // >>> bar
27+
// STEP_END
28+
29+
// STEP_START close
30+
connection.close();
31+
client.shutdown();
32+
// STEP_END
33+
}
34+
}

0 commit comments

Comments
 (0)