Merge pull request #74 from redis/bugfix/#73-module-list-not-working-on-redis-enterprise

Changed the way that modules are detected to work with Redis Enterprise
This commit is contained in:
Simon Prickett 2022-01-07 20:02:52 +00:00 committed by GitHub
commit 544a9c0d64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,18 +5,16 @@ from aredis_om.connections import get_redis_connection
@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):
@ -24,5 +22,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