Redis stores data in memory for fast access. What is the main reason memory optimization is crucial in Redis?
Think about what makes Redis fast and what limits its data size.
Redis keeps data in RAM for speed. Optimizing memory lets Redis hold more data in memory, reducing slow disk access and improving response times.
Given the Redis INFO memory command output snippet below, what does the used_memory field represent?
used_memory:1048576 used_memory_rss:2097152 used_memory_peak:3145728
Look for what 'used_memory' typically means in Redis INFO output.
The used_memory field shows the total number of bytes Redis has allocated in RAM for its data and overhead.
Choose the correct Redis command syntax to set a key session with value abc123 that expires after 60 seconds.
Remember the commands that set a key and expiration in one step.
SETEX key seconds value sets a key with a value and expiration time in seconds. Also, SET key value EX seconds and SET key value PX milliseconds are valid. Option D is incorrect.
You need to store thousands of small strings in Redis. Which data structure choice is best for memory optimization?
Think about how Redis stores hashes efficiently for many small values.
Redis Hashes are memory efficient for many small key-value pairs because they use a compact encoding internally.
You notice Redis memory usage keeps growing even after deleting many keys. What is the most likely reason?
Consider how memory allocators work and what fragmentation means.
Redis memory fragmentation means freed memory is not immediately returned to the OS, so used_memory_rss stays high even after deletions.