0
0
Redisquery~10 mins

Redis with Node.js (ioredis) - 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 Redis client using ioredis.

Redis
const Redis = require('ioredis');
const redis = new [1]();
Drag options to blanks, or click blank then click option'
ARedis
Bredis
Cioredis
Dclient
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'redis' instead of 'Redis' causes an error.
Trying to use 'client' without importing it.
2fill in blank
medium

Complete the code to set a key 'name' with value 'Alice' in Redis.

Redis
await redis.[1]('name', 'Alice');
Drag options to blanks, or click blank then click option'
Aset
Bdel
Cget
Dexists
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'set' will not store the value.
Using 'del' deletes keys, not sets them.
3fill in blank
hard

Fix the error in the code to get the value of key 'name' from Redis.

Redis
const value = await redis.[1]('name');
Drag options to blanks, or click blank then click option'
Aset
Bdel
Cget
Dexists
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' instead of 'get' causes the value to be overwritten.
Using 'del' deletes the key instead of reading it.
4fill in blank
hard

Fill both blanks to delete the key 'name' and check if it still exists.

Redis
await redis.[1]('name');
const exists = await redis.[2]('name');
Drag options to blanks, or click blank then click option'
Adel
Bexists
Cget
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' to delete a key does not work.
Using 'set' to check existence is incorrect.
5fill in blank
hard

Fill all three blanks to increment a counter, get its value, and then reset it to zero.

Redis
await redis.[1]('counter');
const count = await redis.[2]('counter');
await redis.[3]('counter', 0);
Drag options to blanks, or click blank then click option'
Aincr
Bget
Cset
Ddel
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' to increment does not work.
Using 'del' instead of 'set' to reset deletes the key.