def _do(p: redis.client.Pipeline, number): p.watch(number) if p.get(number): raise AlreadyExistException('Number already exists') elif p.get(number + 1): raise OneLessThatItWasException('Number is 1 less than required') p.execute() p.unwatch() p.set(number, 'True') p.execute()
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)