Challenge - 5 Problems
Redis Java Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this Jedis command sequence?
Given a Jedis connection, what will be the output of the following commands?
jedis.set("key1", "value1");
String val = jedis.get("key1");
System.out.println(val);Redis
jedis.set("key1", "value1"); String val = jedis.get("key1"); System.out.println(val);
Attempts:
2 left
💡 Hint
Remember that set stores a string value and get retrieves it.
✗ Incorrect
The set command stores the string 'value1' under 'key1'. The get command retrieves it, so the output is 'value1'.
📝 Syntax
intermediate2:00remaining
Which option correctly initializes a Lettuce Redis client?
Choose the correct Java code snippet to create a Lettuce Redis client connected to localhost on default port 6379.
Attempts:
2 left
💡 Hint
Lettuce uses URI format starting with redis://
✗ Incorrect
The correct way to create a Lettuce client is using RedisClient.create with a redis:// URI.
❓ optimization
advanced2:00remaining
How to optimize multiple Redis commands in Jedis?
You want to execute multiple Redis commands efficiently in Jedis. Which approach reduces network overhead the most?
Attempts:
2 left
💡 Hint
Batching commands reduces round-trip time.
✗ Incorrect
Pipelining batches commands and sends them in one network call, reducing overhead.
🔧 Debug
advanced2:00remaining
Why does this Lettuce code throw a NullPointerException?
Consider this Lettuce code snippet:
What causes the NullPointerException?
RedisClient client = RedisClient.create("redis://localhost:6379");
StatefulRedisConnection connection = null;
RedisCommands syncCommands = connection.sync();
syncCommands.set("key", "value"); What causes the NullPointerException?
Redis
RedisClient client = RedisClient.create("redis://localhost:6379"); StatefulRedisConnection<String, String> connection = null; RedisCommands<String, String> syncCommands = connection.sync(); syncCommands.set("key", "value");
Attempts:
2 left
💡 Hint
Check which variable is null before method call.
✗ Incorrect
The connection variable is null, so calling connection.sync() throws NullPointerException.
🧠 Conceptual
expert2:00remaining
What is the main difference between Jedis and Lettuce clients?
Which statement best describes the key difference between Jedis and Lettuce Redis clients in Java?
Attempts:
2 left
💡 Hint
Think about how each client handles command execution style.
✗ Incorrect
Jedis primarily offers synchronous blocking calls, while Lettuce supports asynchronous and reactive programming models.