Redis 8.8 introduces a native array data type designed by Salvatore Sanfilippo, offering O(1) index access — something no existing Redis type (list, hash, set, sorted set) provides. The array divides its index space into groups of 4096 slots, allocating memory only for groups that receive writes, making sparse data cheap to store and fast to scan. Key commands include ARSET/ARGET for positional access, ARRING for fixed-size circular buffers (replacing LPUSH+LTRIM), ARSCAN for iterating only occupied slots, ARGREP for server-side pattern matching with GLOB/regex support, and AROP for server-side aggregations (SUM, MIN, MAX, USED). The internal structure starts as a flat two-level directory and auto-promotes to a three-level superdir structure when indices exceed ~8.3M. Practical use cases include document line indexing, network port allocation, fixed-size event logs, and sparse log analysis. The post also clarifies when to prefer lists (insertion order matters), hashes (named fields), sets (membership), or sorted sets (score as metadata) over the new array type.

28m read timeFrom redis.io
Post cover image
Table of contents
Why a new data type?What you can build with arrayHow the array data type works internallyWhen other data types are still the right choiceTrying it
210 Impressions