From 2753ce93a24be571f071895f447a24e0093f4a66 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 12 Dec 2022 18:01:02 +0700 Subject: [PATCH] add contains to RedisQueue --- tubearchivist/home/src/ta/ta_redis.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tubearchivist/home/src/ta/ta_redis.py b/tubearchivist/home/src/ta/ta_redis.py index e963dfdd..40529cd3 100644 --- a/tubearchivist/home/src/ta/ta_redis.py +++ b/tubearchivist/home/src/ta/ta_redis.py @@ -114,6 +114,11 @@ class RedisQueue(RedisBase): all_elements = [i.decode() for i in result] return all_elements + def contains(self, element): + """check if element is in list""" + result = self.conn.execute_command("LPOS", self.key, element) + return result is not None + def add_list(self, to_add): """add list to queue""" self.conn.execute_command("RPUSH", self.key, *to_add)