There are three main commands when working with Redis HyperLogLogs. These commands include:
- PFADD command
- PFCOUNT command
- PFMERGE command.
Let us take an example.
Assume we have a database that holds the type of databases we support. We can add each entry to the HyperLogLog as:
127.0.0.1:6379> PFADD databases MongoDB
127.0.0.1:6379> PFADD databases PostgreSQL
127.0.0.1:6379> PFADD databases Oracle
To see the number of databases supported, we can run:
Let us also assume that we have a list of unsupported databases:
To create a union of both supported and unsupported databases, we can use the PFMERGE command as shown:
We can then count the number of databases in the new key is:
This tutorial covered how to work with Redis HyperLogLog using PFADD, PFCOUNT, and PFMERGE commands.