[{"id":"redisadvanced-001","courseId":"redis-advanced","domain":"data-structures","topic":"Embedded string length limit","prompt":"A key holds a 50-byte text value that is not a number. It was set with SET on Redis 7.2. What does OBJECT ENCODING return for that key?","hint":"Compare the value's size with the size cap on the short-string encoding.","source":"https://redis.io/docs/latest/commands/object-encoding/","interaction":{"type":"single"},"options":[{"id":"a","text":"raw","why":"Strings longer than the 44-byte embstr limit, and that are not integers, use the normal raw encoding."},{"id":"b","text":"embstr","whyNot":"embstr covers only strings up to 44 bytes, so a 50-byte value does not qualify."},{"id":"c","text":"int","whyNot":"int is only for strings that represent integers in the 64-bit signed range, and this value is text."},{"id":"d","text":"listpack","whyNot":"listpack is a compact encoding for lists, hashes, sets and sorted sets, not for strings."}],"answer":"a","explanation":"embstr holds strings up to 44 bytes (OBJ_ENCODING_EMBSTR_SIZE_LIMIT); longer strings that are not integers use the raw encoding.","concept":"embstr holds strings up to 44 bytes (OBJ_ENCODING_EMBSTR_SIZE_LIMIT); longer strings that are not integers use the raw encoding.","rev":1,"kind":"scenario","takeaways":["Do not guess the encoding of a string from how short it looks; check OBJECT ENCODING."]},{"id":"redisadvanced-002","courseId":"redis-advanced","domain":"data-structures","topic":"Integer set encoding","prompt":"On Redis 7.2 with default settings, you create a set that holds only integers and grow it to 600 members. What does OBJECT ENCODING report for the set?","hint":"Think about what happens when a special encoding passes its configured size limit.","source":"https://redis.io/docs/latest/commands/object-encoding/","interaction":{"type":"single"},"options":[{"id":"a","text":"hashtable","why":"Past set-max-intset-entries (512 by default), Redis converts the set to the normal hashtable encoding."},{"id":"b","text":"intset","whyNot":"intset is only for small sets, so an all-integer set stays intset at any length."},{"id":"c","text":"listpack","whyNot":"listpack is for small sets, and the default set-max-listpack-entries is 128, which 600 exceeds."},{"id":"d","text":"skiplist","whyNot":"skiplist is the sorted set encoding; plain sets never use it."}],"answer":"a","explanation":"intset stores small all-integer sets; once a set outgrows set-max-intset-entries (512 by default), it converts to the normal hashtable encoding.","concept":"intset stores small all-integer sets; once a set outgrows set-max-intset-entries (512 by default), it converts to the normal hashtable encoding.","rev":1,"kind":"scenario","takeaways":["An integer-only set loses its intset encoding when it grows past the configured entry limit."]},{"id":"redisadvanced-003","courseId":"redis-advanced","domain":"data-structures","topic":"Compact hash thresholds","prompt":"A hash on Redis 7.4 with default settings currently reports listpack. Which TWO changes will make OBJECT ENCODING report hashtable?","hint":"Two configured limits decide when a compact hash turns into the normal one.","source":"https://redis.io/docs/latest/operate/oss_and_stack/management/optimization/memory-optimization/","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Add a 513th field to the hash","why":"hash-max-listpack-entries defaults to 512, so one more field overflows the compact encoding."},{"id":"b","text":"Store a 65-byte value in one field","why":"hash-max-listpack-value defaults to 64 bytes, so a longer value forces the normal encoding."},{"id":"c","text":"Change the hash to 300 fields of 10 bytes each","whyNot":"300 fields is under the 512-entry limit and 10-byte values are under 64 bytes, so the hash stays compact."},{"id":"d","text":"Read every field with HGETALL in a loop","whyNot":"Reads never convert the encoding; only an overflow of the entry count or the value size does."}],"answer":"ab","explanation":"A compact hash converts to the hashtable encoding when its entries exceed hash-max-listpack-entries (512) or a value exceeds hash-max-listpack-value (64 bytes).","concept":"A compact hash converts to the hashtable encoding when its entries exceed hash-max-listpack-entries (512) or a value exceeds hash-max-listpack-value (64 bytes).","rev":1,"kind":"scenario","takeaways":["One oversized field can change the encoding of the whole hash, not just that field."]},{"id":"redisadvanced-004","courseId":"redis-advanced","domain":"data-structures","topic":"Hash field expiration","prompt":"On Redis 7.4, the hash app:sess has a field named session but no field named token. What does this command reply with?","hint":"Each field in the list gets its own result code in the reply.","source":"https://redis.io/docs/latest/commands/hexpire/","interaction":{"type":"single"},"options":[{"id":"a","text":"[1, -2]","why":"session gets a TTL, so it returns 1, and token returns -2 because no such field exists."},{"id":"b","text":"[1, 1]","whyNot":"HEXPIRE does not create a missing field, so token cannot report 1."},{"id":"c","text":"[1, 0]","whyNot":"0 means the expiry was not set because a condition failed; a missing field reports -2."},{"id":"d","text":"[]","whyNot":"An empty array comes back only when the whole key is missing, and app:sess exists."}],"answer":"a","explanation":"HEXPIRE replies with one code per field: 1 when a TTL is set, 0 when a condition blocks it, 2 when the field is already due and deleted, and -2 when the field does not exist.","concept":"HEXPIRE replies with one code per field: 1 when a TTL is set, 0 when a condition blocks it, 2 when the field is already due and deleted, and -2 when the field does not exist.","rev":1,"kind":"scenario","code":"HEXPIRE app:sess 60 FIELDS 2 session token","takeaways":["Read each code in a HEXPIRE reply; -2 flags a field that is missing from the hash."]},{"id":"redisadvanced-005","courseId":"redis-advanced","domain":"data-structures","topic":"Bitfield overflow modes","prompt":"The key hits holds the u8 value 250 at offset 0. Which value does this command return?","hint":"The overflow mode is set once and applies to the operations that follow it.","source":"https://redis.io/docs/latest/commands/bitfield/","interaction":{"type":"single"},"options":[{"id":"a","text":"255","why":"SAT clamps the result to the u8 maximum of 255 instead of wrapping around."},{"id":"b","text":"4","whyNot":"4 is the WRAP result, but OVERFLOW SAT applies to this INCRBY, so WRAP is not used."},{"id":"c","text":"nil","whyNot":"nil comes from OVERFLOW FAIL; SAT never returns nil on overflow."},{"id":"d","text":"250","whyNot":"A saturating overflow moves the field to its limit; it does not leave the old value in place."}],"answer":"a","explanation":"OVERFLOW sets how the following SET and INCRBY handle overflow: WRAP (the default), SAT clamps to the type's min or max, and FAIL returns nil.","concept":"OVERFLOW sets how the following SET and INCRBY handle overflow: WRAP (the default), SAT clamps to the type's min or max, and FAIL returns nil.","rev":1,"kind":"scenario","code":"BITFIELD hits OVERFLOW SAT INCRBY u8 0 10","takeaways":["OVERFLOW is positional inside BITFIELD: it changes only the SET and INCRBY operations after it."]}]