0
0
Redisquery~10 mins

Set vs sorted set for membership in Redis - Interactive Practice

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

Complete the code to check if a member exists in a Redis set.

Redis
EXISTS = redis.sismember('myset', [1])
Drag options to blanks, or click blank then click option'
A'member1'
B'sortedset'
C'zadd'
D'score'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sorted set commands like ZADD instead of set commands.
Not quoting the member name as a string.
2fill in blank
medium

Complete the code to add a member with a score to a Redis sorted set.

Redis
redis.[1]('myzset', 10, 'member1')
Drag options to blanks, or click blank then click option'
Asadd
Bzadd
Czrange
Dsmembers
Attempts:
3 left
💡 Hint
Common Mistakes
Using sadd which does not accept scores.
Using smembers which lists members but does not add.
3fill in blank
hard

Fix the error in the code to check membership in a sorted set.

Redis
exists = redis.[1]('myzset', 'member1')
Drag options to blanks, or click blank then click option'
Asismember
Bzrem
Czrank
Dzscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using sismember which only works for sets, not sorted sets.
Using zrem which removes members instead of checking.
4fill in blank
hard

Fill both blanks to create a Redis set and add a member.

Redis
redis.[1]('myset')
redis.[2]('myset', 'member1')
Drag options to blanks, or click blank then click option'
Adelete
Bsadd
Czadd
Dexists
Attempts:
3 left
💡 Hint
Common Mistakes
Using zadd which is for sorted sets, not sets.
Trying to add members before deleting existing keys.
5fill in blank
hard

Fill all three blanks to check membership in a set and a sorted set.

Redis
is_in_set = redis.[1]('myset', 'member1')
is_in_zset = redis.[2]('myzset', 'member1') is not None
redis.[3]('myzset', 5, 'member2')
Drag options to blanks, or click blank then click option'
Asismember
Bzscore
Czadd
Dsmembers
Attempts:
3 left
💡 Hint
Common Mistakes
Using sismember for sorted sets.
Using smembers to check membership instead of sismember.