Skip to content

Changed the way that modules are detected to work with Redis Enterprise #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions aredis_om/checks.py
Original file line number Diff line number Diff line change
@@ -5,24 +5,22 @@


@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):
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):
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):
if conn is 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