Skip to content

Commit 338f735

Browse files
Merge pull request #2278 from redis/DOC-5838-notebook-links
DOC-5838 notebook links
2 parents 5038e93 + 19556cc commit 338f735

File tree

4 files changed

+62
-23
lines changed

4 files changed

+62
-23
lines changed

content/develop/clients/jedis/_index.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,38 +58,31 @@ To include `Jedis` as a dependency in your application, edit the dependency file
5858

5959
## Connect and test
6060

61-
The following code opens a basic connection to a local Redis server
62-
and closes it after use.
61+
Add the following imports to your source file:
6362

64-
```java
65-
package org.example;
66-
import redis.clients.jedis.UnifiedJedis;
63+
{{< clients-example set="landing" step="import" lang_filter="Java-Sync" >}}
64+
{{< /clients-example >}}
6765

68-
public class Main {
69-
public static void main(String[] args) {
70-
UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379");
66+
Connect to localhost on port 6379:
7167

72-
// Code that interacts with Redis...
73-
74-
jedis.close();
75-
}
76-
}
77-
```
68+
{{< clients-example set="landing" step="connect" lang_filter="Java-Sync" >}}
69+
{{< /clients-example >}}
7870

7971
After you have connected, you can check the connection by storing and
80-
retrieving a simple string value:
72+
retrieving a simple [string]({{< relref "/develop/data-types/strings" >}}) value:
73+
74+
{{< clients-example set="landing" step="set_get_string" lang_filter="Java-Sync" >}}
75+
{{< /clients-example >}}
8176

82-
```java
83-
...
77+
Store and retrieve a [hash]({{< relref "/develop/data-types/hashes" >}}):
8478

85-
String res1 = jedis.set("bike:1", "Deimos");
86-
System.out.println(res1); // OK
79+
{{< clients-example set="landing" step="set_get_hash" lang_filter="Java-Sync" >}}
80+
{{< /clients-example >}}
8781

88-
String res2 = jedis.get("bike:1");
89-
System.out.println(res2); // Deimos
82+
Close the connection when you're done:
9083

91-
...
92-
```
84+
{{< clients-example set="landing" step="close" lang_filter="Java-Sync" >}}
85+
{{< /clients-example >}}
9386

9487
## More information
9588

local_examples/client-specific/dotnet-async/AsyncLandingExample.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// EXAMPLE: landing
2+
// BINDER_ID netasync-landing
23
// STEP_START import
34
using NRedisStack;
45
using NRedisStack.RedisStackCommands;

local_examples/client-specific/dotnet-sync/SyncLandingExample.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// EXAMPLE: landing
2+
// BINDER_ID netsync-landing
23
// STEP_START import
34
using NRedisStack;
45
using NRedisStack.RedisStackCommands;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// EXAMPLE: landing
2+
// BINDER_ID jedis-landing
3+
// STEP_START import
4+
import redis.clients.jedis.UnifiedJedis;
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
// STEP_END
8+
9+
public class LandingExample {
10+
11+
@Test
12+
public void run() {
13+
// STEP_START connect
14+
UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379");
15+
// STEP_END
16+
17+
// STEP_START set_get_string
18+
String res1 = jedis.set("bike:1", "Deimos");
19+
System.out.println(res1); // >>> OK
20+
21+
String res2 = jedis.get("bike:1");
22+
System.out.println(res2); // >>> Deimos
23+
// STEP_END
24+
25+
// STEP_START set_get_hash
26+
Map<String, String> hash = new HashMap<>();
27+
hash.put("name", "John");
28+
hash.put("surname", "Smith");
29+
hash.put("company", "Redis");
30+
hash.put("age", "29");
31+
32+
Long res3 = jedis.hset("user-session:123", hash);
33+
System.out.println(res3); // >>> 4
34+
35+
Map<String, String> res4 = jedis.hgetAll("user-session:123");
36+
System.out.println(res4);
37+
// >>> {name=John, surname=Smith, company=Redis, age=29}
38+
// STEP_END
39+
40+
// STEP_START close
41+
jedis.close();
42+
// STEP_END
43+
}
44+
}

0 commit comments

Comments
 (0)