Creating memory efficient Redis data structures
The following are some of the methods for memory optimization in Redis:
Small aggregate hashes, lists, sets, and sorted sets
For hashes, lists, and sorted sets, this special encoding is based on ziplist A Ziplist is described from ziplist.c
as follows:
The ziplist is a specially encoded dually linked list that is designed to be very memory efficient. It stores both strings and integer values, where integers are encoded as actual integers instead of a series of characters. It allows push and pop operations on either side of the list in O(1) time. However, because every operation requires a reallocation of the memory used by the ziplist, the actual complexity is related to the amount of memory used by the ziplist.2
.
Depending on the size, type, and contents of the data structure, the ziplist encoding offers significant memory savings for your Redis database. Redis dynamically switches between the ziplist and the default encoding for the data structure...