@@ -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
7971After 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
0 commit comments