From e9fbd56e4eb167f591483090b0329300ca2fa881 Mon Sep 17 00:00:00 2001 From: Simon Prickett Date: Thu, 6 Jan 2022 15:51:56 +0000 Subject: [PATCH 1/2] Changed the way that modules are detected to work with Redis Enterprise and OSS. --- aredis_om/checks.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/aredis_om/checks.py b/aredis_om/checks.py index 00c50844..882c69de 100644 --- a/aredis_om/checks.py +++ b/aredis_om/checks.py @@ -5,18 +5,19 @@ @lru_cache(maxsize=None) -async def get_modules(conn) -> List[str]: - modules = await conn.execute_command("module", "list") - return [m[1] for m in modules] - +async def check_for_command(conn, cmd): + try: + cmd_info = await conn.execute_command("command", "info", cmd) + return True + except TypeError: + return False @lru_cache(maxsize=None) async def has_redis_json(conn=None): if conn is None: conn = get_redis_connection() - names = await get_modules(conn) - return b"ReJSON" in names or "ReJSON" in names - + command_exists = await check_for_command(conn, "json.set") + return command_exists @lru_cache(maxsize=None) async def has_redisearch(conn=None): @@ -24,5 +25,5 @@ async def has_redisearch(conn=None): conn = get_redis_connection() if has_redis_json(conn): return True - names = await get_modules(conn) - return b"search" in names or "search" in names + command_exists = await check_for_command(conn, "ft.search") + return command_exists From d60fce52315afc2606639f0d9f144788bd4916a0 Mon Sep 17 00:00:00 2001 From: Simon Prickett Date: Thu, 6 Jan 2022 21:10:53 +0000 Subject: [PATCH 2/2] Fixed check for presence of modules. --- aredis_om/checks.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/aredis_om/checks.py b/aredis_om/checks.py index 882c69de..a274f14b 100644 --- a/aredis_om/checks.py +++ b/aredis_om/checks.py @@ -6,11 +6,8 @@ @lru_cache(maxsize=None) async def check_for_command(conn, cmd): - try: - cmd_info = await conn.execute_command("command", "info", cmd) - return True - except TypeError: - return False + cmd_info = await conn.execute_command("command", "info", cmd) + return not None in cmd_info @lru_cache(maxsize=None) async def has_redis_json(conn=None):