Storing Set in Redis: Insertion Commands

Learn about the commands to store sets in Redis database.

In an earlier lesson, we looked at storing lists of elements in Redis. The problem with a list is that it allows duplicate elements. If we need to add unique elements, we can use a Set instead of a List.

Redis internally uses a hash table to store the elements as a Set. The image below depicts how elements are stored in a Set. There is no particular order. The elements are stored randomly, and repetition is not allowed.

Get hands-on with 1200+ tech skills courses.