Skip to content

Commit e9fbd56

Browse files
author
Simon Prickett
committed
Changed the way that modules are detected to work with Redis Enterprise and OSS.
1 parent 8a661c9 commit e9fbd56

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

aredis_om/checks.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,25 @@
55

66

77
@lru_cache(maxsize=None)
8-
async def get_modules(conn) -> List[str]:
9-
modules = await conn.execute_command("module", "list")
10-
return [m[1] for m in modules]
11-
8+
async def check_for_command(conn, cmd):
9+
try:
10+
cmd_info = await conn.execute_command("command", "info", cmd)
11+
return True
12+
except TypeError:
13+
return False
1214

1315
@lru_cache(maxsize=None)
1416
async def has_redis_json(conn=None):
1517
if conn is None:
1618
conn = get_redis_connection()
17-
names = await get_modules(conn)
18-
return b"ReJSON" in names or "ReJSON" in names
19-
19+
command_exists = await check_for_command(conn, "json.set")
20+
return command_exists
2021

2122
@lru_cache(maxsize=None)
2223
async def has_redisearch(conn=None):
2324
if conn is None:
2425
conn = get_redis_connection()
2526
if has_redis_json(conn):
2627
return True
27-
names = await get_modules(conn)
28-
return b"search" in names or "search" in names
28+
command_exists = await check_for_command(conn, "ft.search")
29+
return command_exists

0 commit comments

Comments
 (0)