Example #1
0
    def add_items(self, items: list):
        """
        :param items: List of items to be added via pipeline
        """
        pipeline = self.redis.pipeline()

        for chunk in helpers.create_chunks(items, CHUNK_SIZE):
            pipeline.lpush(self.name, *chunk)
        pipeline.execute()
        self._wait_for_synced_slaves()
Example #2
0
 def remove_items(self, items):
     """ Removes an item that is no longer valid
     :param items: List of items that are convertible to str
     """
     for chunk in helpers.create_chunks(items, self.options['chunk_size']):
         pipeline = self.redis.pipeline()
         for item in chunk:
             self.remove_command(keys=[self.name],
                                 args=[item])
         pipeline.execute()
         self._wait_for_synced_slaves()
Example #3
0
 def ack_items(self, items):
     """ Acknowledges items that were processed correctly
     :param items: List of items that are convertible to str
     """
     for chunk in helpers.create_chunks(items, self.options['chunk_size']):
         pipeline = self.redis.pipeline()
         for item in chunk:
             self.ack_command(keys=[self.name],
                              args=[item, int(time.time()) + self.options['ack_valid_for']])
         pipeline.execute()
         self._wait_for_synced_slaves()
Example #4
0
 def add_items(self, items):
     """
     :param items: List of items to be added via pipeline
     """
     pipeline = self.redis.pipeline()
     for chunk in helpers.create_chunks(items, self.options['chunk_size']):
         current_time = int(time.time())
         prepared_items = []
         for item in chunk:
             prepared_items.append(item)
             prepared_items.append(current_time)
         pipeline.zadd(self.name, *prepared_items)
     pipeline.execute()
     self._wait_for_synced_slaves()