Esempio n. 1
0
 def _add_match_items_to_redis(
     cls,
     match_item_generator: ABCMatchItemGenerator,
     redis_pipeline: redis.client.Pipeline,
     redis_prefix: str,
 ) -> None:
     prefix = cls.add_to_prefix(redis_prefix, match_item_generator.name)
     key_match_texts = cls.key_match_texts(prefix)
     redis_pipeline.delete(key_match_texts)
     for idx, match_item in enumerate(match_item_generator.generate_match_items()):
         redis_pipeline.hset(
             key_match_texts,
             key=" ".join(match_item.match_texts),
             value=idx,
         )
         redis_pipeline.hset(  # type: ignore[call-arg]  # no idea why this is necessary...
             cls.add_to_prefix(prefix, idx),
             mapping={
                 "title": match_item.title,
                 "topic": match_item.topic,
                 "url": match_item.url,
             },
         )
Esempio n. 2
0
 def transaction_method(pipe: redis.client.Pipeline) -> None:
     value = pipe.get(db_key)
     if value is not None and \
             value.decode("utf-8") == expected_report_key:
         pipe.delete(db_key)