File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 5
5
6
6
7
7
@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
12
14
13
15
@lru_cache (maxsize = None )
14
16
async def has_redis_json (conn = None ):
15
17
if conn is None :
16
18
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
20
21
21
22
@lru_cache (maxsize = None )
22
23
async def has_redisearch (conn = None ):
23
24
if conn is None :
24
25
conn = get_redis_connection ()
25
26
if has_redis_json (conn ):
26
27
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
You can’t perform that action at this time.
0 commit comments