From c4d6bb35a376ca8d8cef642e027a2abb214172db Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 24 Feb 2022 18:55:18 +0700 Subject: [PATCH] add list_items for wildcard matching --- tubearchivist/home/src/ta/ta_redis.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tubearchivist/home/src/ta/ta_redis.py b/tubearchivist/home/src/ta/ta_redis.py index d131c96..6a9efea 100644 --- a/tubearchivist/home/src/ta/ta_redis.py +++ b/tubearchivist/home/src/ta/ta_redis.py @@ -59,6 +59,19 @@ class RedisArchivist: return json_str + def list_items(self, query): + """list all matches""" + reply = self.redis_connection.execute_command( + "KEYS", self.NAME_SPACE + query + "*" + ) + all_matches = [i.decode().lstrip(self.NAME_SPACE) for i in reply] + all_results = [] + for match in all_matches: + json_str = self.get_message(match) + all_results.append(json_str) + + return all_results + def del_message(self, key): """delete key from redis""" response = self.redis_connection.execute_command(