Redis Set – Commands to manage a set value in redis datastore

5 years ago Lalit Bhagtani 0

Sets are an unordered collection of unique elements, In Redis, sets can be store as a value at key and several redis commands are used to store, manage and retrieved a set value stored in redis database. The syntax for using redis commands is as follows :-

Syntax :-

redis host:post> <Command Name> <key name>

Example :-

Redis SET

Redis Set Value Commands :- 

Some of the important commands to manage set value in redis database are as follows :-

S.No Command Description
1 SADD Adds one or more elements in the set
2 SCARD Returns size of the set
3 SDIFF Performs difference operation on multiple sets
4 SDIFFSTORE Performs difference operation on multiple sets and store result in a key
5 SINTER Performs intersection operation on multiple sets
6 SINTERSTORE Performs intersection operation on multiple sets and store result in a key
7 SISMEMBER Checks whether a given element is a member of the set or not
8 SMEMBERS Returns all the elements of a set
9 SMOVE Moves an element from one set to another
10 SPOP Removes and return a random element from the set
11 SRANDMEMBER Returns one or more random element from the set
12 SREM Removes one or more elements from the set
13 SUNION Performs union operation on multiple sets
14 SUNIONSTORE Performs union operation on multiple sets and store result in a key
15 SSCAN Incrementally iterates set elements

 

References :-

  1. Set Command Docs

That’s all for Redis set value and commands used to store and manage it in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.