-
-
Save yhemanth/65319116e1ccdb2b7eaf to your computer and use it in GitHub Desktop.
Adding IDs to a Redis HLL key using pipelining
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __add_to_hll(self): | |
self.redis_client.delete(self.hll_key_name) | |
pipeline = self.redis_client.pipeline() | |
batch_size = REDIS_PIPELINE_BATCH_SIZE | |
for hll_id in self.ids: | |
pipeline.pfadd(self.hll_key_name, hll_id) | |
batch_size -= 1 | |
if batch_size == 0: | |
pipeline.execute() | |
batch_size = REDIS_PIPELINE_BATCH_SIZE | |
pipeline.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment