APPENDIX · P4 · REDIS · FOR SLIDES 13–14
← Back to Slide 13
P4. Types, secondary indexes, and SCAN
HGET player:1042:profile level
HINCRBY player:1042:profile level 1
TYPE player:1042:profile
GET player:1042:profile
SMEMBERS region:eu:players
RPUSH matchmaking:queue:ranked 3003
LPOP matchmaking:queue:ranked
SCAN 0 MATCH player:* COUNT 100
What the result should be
"13"
(integer) 14
hash
(error) WRONGTYPE …
1042 and 2001 (the order of the set is arbitrary)
(integer) 3; then "1042" (FIFO)
SCAN: cursor and found keys—no fixed order
WRONGTYPE
Your Index
SCAN to 0
There is one type of value: the hash is retrieved using HGET, not GET.
region:eu:players — a secondary index that the application updates.
A "0" in the response indicates the end of the loop. An empty segment does not indicate the end.
This is lab data. When HINCRBY and RPUSH are run again, their status changes. For the local lab—dba/appendix.md; Redis logs the result of each command and after WRONGTYPE.