Hint: Count characters added stepwise, including spaces [OK]
Common Mistakes:
Counting quotes as characters
Forgetting spaces in appended strings
Adding lengths incorrectly
4. You run the command APPEND mykey "text" but get an error: "WRONGTYPE Operation against a key holding the wrong kind of value". What is the most likely cause?
medium
A. The key 'mykey' does not exist yet.
B. The key 'mykey' holds a non-string value like a list or set.
C. The APPEND command syntax is incorrect.
D. Redis server is down.
Solution
Step 1: Understand the error message
"WRONGTYPE" means the key exists but is not a string type.
Step 2: Analyze possible causes
If the key held a string or did not exist, APPEND would work or create it. Syntax error or server down would cause different errors.
Final Answer:
The key 'mykey' holds a non-string value like a list or set. -> Option B
Quick Check:
WRONGTYPE means key type mismatch [OK]
Hint: WRONGTYPE means key is not a string [OK]
Common Mistakes:
Assuming key absence causes WRONGTYPE
Blaming syntax for WRONGTYPE error
Ignoring key data type
5. You want to build a Redis string key 'log' that starts empty and appends multiple messages separated by commas. Which sequence of commands correctly achieves this without leading commas?
hard
A. APPEND log ",message1" APPEND log ",message2" APPEND log ",message3"
B. APPEND log "message1" APPEND log "message2" APPEND log "message3"
C. SET log "message1" APPEND log ",message2" APPEND log ",message3"
D. SET log "message1," APPEND log "message2," APPEND log "message3,"
Solution
Step 1: Initialize the key without leading comma
Use SET to start 'log' with "message1" (no comma at start).
Step 2: Append subsequent messages with leading commas
Use APPEND to add ",message2" and ",message3" to separate messages properly.
Step 3: Verify no leading comma and correct separators
SET log "message1" APPEND log ",message2" APPEND log ",message3" correctly avoids leading comma and separates messages with commas.
Final Answer:
SET log "message1" APPEND log ",message2" APPEND log ",message3" -> Option C
Quick Check:
Start with SET, then APPEND with commas [OK]
Hint: Start with SET, then APPEND with commas to separate [OK]
Common Mistakes:
Starting with APPEND adding commas first
Appending without commas causing merged words
Adding trailing commas unnecessarily
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.