add list_items for wildcard matching

This commit is contained in:
simon 2022-02-24 18:55:18 +07:00
parent e0db73543e
commit c4d6bb35a3
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -59,6 +59,19 @@ class RedisArchivist:
return json_str 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): def del_message(self, key):
"""delete key from redis""" """delete key from redis"""
response = self.redis_connection.execute_command( response = self.redis_connection.execute_command(