Your cart is currently empty!
Author: alien
-
Khóa học miễn phí Redis – HyperLogLog nhận dự án làm có lương
Redis – HyperLogLog
Redis HyperLogLog is an algorithm that uses randomization in order to provide an approximation of the number of unique elements in a set using just a constant, and small amount of memory.
HyperLogLog provides a very good approximation of the cardinality of a set even using a very small amount of memory around 12 kbytes per key with a standard error of 0.81%. There is no limit to the number of items you can count, unless you approach 264 items.
Example
Following example explains how Redis HyperLogLog works.
redis 127.0.0.1:6379> PFADD tutorials "redis" 1) (integer) 1 redis 127.0.0.1:6379> PFADD tutorials "mongodb" 1) (integer) 1 redis 127.0.0.1:6379> PFADD tutorials "mysql" 1) (integer) 1 redis 127.0.0.1:6379> PFCOUNT tutorials (integer) 3
Redis HyperLogLog Commands
Following table lists some basic commands related to Redis HyperLogLog.
Sr.No Command & Description 1 Adds the specified elements to the specified HyperLogLog.
2 Returns the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).
3 Merges N different HyperLogLogs into a single one.
Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc
Khóa học miễn phí Redis – Sets nhận dự án làm có lương
Redis – Sets
Redis Sets are an unordered collection of unique strings. Unique means sets does not allow repetition of data in a key.
In Redis set add, remove, and test for the existence of members in O(1) (constant time regardless of the number of elements contained inside the Set). The maximum length of a list is 232 – 1 elements (4294967295, more than 4 billion of elements per set).
Example
redis 127.0.0.1:6379> SADD tutorials redis (integer) 1 redis 127.0.0.1:6379> SADD tutorials mongodb (integer) 1 redis 127.0.0.1:6379> SADD tutorials mysql (integer) 1 redis 127.0.0.1:6379> SADD tutorials mysql (integer) 0 redis 127.0.0.1:6379> SMEMBERS tutorials 1) "mysql" 2) "mongodb" 3) "redis"
In the above example, three values are inserted in Redis set named ‘tutorials’ by the command SADD.
Redis Sets Commands
Following table lists some basic commands related to sets.
Sr.No | Command & Description |
---|---|
1 |
Adds one or more members to a set |
2 |
Gets the number of members in a set |
3 |
Subtracts multiple sets |
4 |
Subtracts multiple sets and stores the resulting set in a key |
5 |
Intersects multiple sets |
6 |
Intersects multiple sets and stores the resulting set in a key |
7 |
Determines if a given value is a member of a set |
8 |
Gets all the members in a set |
9 |
Moves a member from one set to another |
10 |
Removes and returns a random member from a set |
11 |
Gets one or multiple random members from a set |
12 |
Removes one or more members from a set |
13 |
Adds multiple sets |
14 |
Adds multiple sets and stores the resulting set in a key |
15 |
Incrementally iterates set elements |
Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc