Explain redis Sorted Set operation.

ZADD : Adds all the specified members with the specified scores to the sorted set stored at key.
 
Time complexity : O(log(N)) for each item added, where N is the number of elements in the sorted set.
 
ZREM : Removes the specified members from the sorted set stored at key. Non existing members are ignored.
 
Time complexity : O(M*log(N)) with N being the number of elements in the sorted set and M the number of elements to be removed.
 
ZRANGE : Returns the specified range of elements in the sorted set stored at key.
 
Time complexity : O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.
 
ZRANGEBYSCORE : Returns all the elements in the sorted set at key with a score between min and max.
 
Time complexity : O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
 
127.0.0.1:6379> ZADD TEST_ZKEY 1 A

(integer) 1

127.0.0.1:6379> ZADD TEST_ZKEY 2 B

(integer) 1

127.0.0.1:6379> ZADD TEST_ZKEY 1 C

(integer) 1

127.0.0.1:6379> ZRANGE TEST_ZKEY 0 -1

1) "A"

2) "C"

3) "B"

127.0.0.1:6379> ZREM TEST_ZKEY B

(integer) 1

127.0.0.1:6379> ZRANGE TEST_ZKEY 0 -1

1) "A"

2) "C"

127.0.0.1:6379> ZRANGEBYSCORE TEST_ZKEY 1 2 {Here 1 is min rank, 2 is max rank- gets a data from rank of 1 to 2}

1) "A"