0
0
Redisquery~10 mins

Counter pattern in Redis - Interactive Code Practice

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

Complete the code to increment a counter named 'page_views' by 1.

Redis
INCR [1]
Drag options to blanks, or click blank then click option'
Acounter
Bviews_count
Cpage_views
Dvisits
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different key name that does not exist.
Forgetting to use the INCR command.
2fill in blank
medium

Complete the code to get the current value of the counter 'user_logins'.

Redis
GET [1]
Drag options to blanks, or click blank then click option'
Alogins
Buser_logins
Clogin_count
Dcount_users
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong key name that does not hold the counter.
Using a command other than GET to retrieve the value.
3fill in blank
hard

Fix the error in the code to decrement the counter 'active_sessions' by 1.

Redis
DECR [1]
Drag options to blanks, or click blank then click option'
Aactive_sessions
Bsessions_active
CactiveSession
Dsession_count
Attempts:
3 left
💡 Hint
Common Mistakes
Using a key name with different spelling or casing.
Using INCR instead of DECR for decrementing.
4fill in blank
hard

Fill both blanks to set the counter 'error_count' to 0 and then increment it by 1.

Redis
SET [1] 0
INCR [2]
Drag options to blanks, or click blank then click option'
Aerror_count
BerrorCount
Cerrors
Dcount_errors
Attempts:
3 left
💡 Hint
Common Mistakes
Using different key names in SET and INCR commands.
Misspelling the key name.
5fill in blank
hard

Fill all three blanks to atomically increment 'page_hits' by 1, set an expiration of 60 seconds, and then get its value.

Redis
MULTI
INCR [1]
EXPIRE [2] [3]
EXEC
Drag options to blanks, or click blank then click option'
Apage_hits
BpageHits
C60
D120
Attempts:
3 left
💡 Hint
Common Mistakes
Using different key names in the transaction.
Setting wrong expiration time.
Forgetting to use MULTI/EXEC for atomicity.