0
0
Redisquery~10 mins

Redis with Java (Jedis, Lettuce) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new Jedis client connection.

Redis
Jedis jedis = new Jedis([1]);
Drag options to blanks, or click blank then click option'
A"localhost"
B"127.0.0.1"
C"redis-server"
D"192.168.1.1"
Attempts:
3 left
💡 Hint
Common Mistakes
Using an incorrect IP address or hostname that does not point to the Redis server.
2fill in blank
medium

Complete the code to set a key "user" with value "Alice" in Redis using Jedis.

Redis
jedis.[1]("user", "Alice");
Drag options to blanks, or click blank then click option'
Aset
Bget
Cdel
Dexists
Attempts:
3 left
💡 Hint
Common Mistakes
Using get which retrieves data instead of setting it.
3fill in blank
hard

Fix the error in the Lettuce code to connect to Redis synchronously.

Redis
RedisClient client = RedisClient.create("redis://localhost:6379");
StatefulRedisConnection<String, String> connection = client.[1]();
Drag options to blanks, or click blank then click option'
Aconnect
BstartConnection
CopenConnection
DconnectAsync
Attempts:
3 left
💡 Hint
Common Mistakes
Using connectAsync() which returns a future, not a direct connection.
4fill in blank
hard

Fill both blanks to set and then get a key "count" using Jedis.

Redis
jedis.[1]("count", "10");
String value = jedis.[2]("count");
Drag options to blanks, or click blank then click option'
Aset
Bget
Cdel
Dexists
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to get a value before setting it.
Using del or exists instead of get.
5fill in blank
hard

Fill all three blanks to create a Lettuce client, connect, and set a key "name" to "Bob".

Redis
RedisClient client = RedisClient.[1]("redis://localhost:6379");
StatefulRedisConnection<String, String> connection = client.[2]();
RedisCommands<String, String> commands = connection.[3]();
commands.set("name", "Bob");
Drag options to blanks, or click blank then click option'
Acreate
Bconnect
Csync
Dopen
Attempts:
3 left
💡 Hint
Common Mistakes
Using open instead of sync for commands.
Confusing connectAsync with connect.