Skip to content

Instantly share code, notes, and snippets.

@yhemanth
Created October 29, 2015 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yhemanth/65319116e1ccdb2b7eaf to your computer and use it in GitHub Desktop.
Save yhemanth/65319116e1ccdb2b7eaf to your computer and use it in GitHub Desktop.
Adding IDs to a Redis HLL key using pipelining
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