@@ -84,25 +84,27 @@ def _process(doc: "Document") -> Dict[str, Any]:
84
84
return [_process (doc ) for doc in results .docs ]
85
85
86
86
87
- def check_modules_present ():
87
+ def setup_redis ():
88
88
def decorator (func ):
89
89
@wraps (func )
90
90
def wrapper (self , * args , ** kwargs ):
91
91
result = func (self , * args , ** kwargs )
92
- RedisConnectionFactory .validate_redis_modules (self ._redis_client )
92
+ RedisConnectionFactory .validate_redis (self ._redis_client , self . _lib_name )
93
93
return result
94
94
95
95
return wrapper
96
96
97
97
return decorator
98
98
99
99
100
- def check_async_modules_present ():
100
+ def setup_async_redis ():
101
101
def decorator (func ):
102
102
@wraps (func )
103
103
def wrapper (self , * args , ** kwargs ):
104
104
result = func (self , * args , ** kwargs )
105
- RedisConnectionFactory .validate_async_redis_modules (self ._redis_client )
105
+ RedisConnectionFactory .validate_async_redis (
106
+ self ._redis_client , self ._lib_name
107
+ )
106
108
return result
107
109
108
110
return wrapper
@@ -175,6 +177,9 @@ def __init__(
175
177
176
178
self .schema = schema
177
179
180
+ # set custom lib name
181
+ self ._lib_name : Optional [str ] = kwargs .pop ("lib_name" , None )
182
+
178
183
# set up redis connection
179
184
self ._redis_client : Optional [Union [redis .Redis , aredis .Redis ]] = None
180
185
if redis_client is not None :
@@ -350,11 +355,13 @@ def connect(self, redis_url: Optional[str] = None, **kwargs):
350
355
index.connect(redis_url="redis://localhost:6379")
351
356
352
357
"""
353
- client = RedisConnectionFactory .connect (redis_url , use_async = False , ** kwargs )
358
+ client = RedisConnectionFactory .connect (
359
+ redis_url = redis_url , use_async = False , ** kwargs
360
+ )
354
361
return self .set_client (client )
355
362
356
- @check_modules_present ()
357
- def set_client (self , client : redis .Redis ):
363
+ @setup_redis ()
364
+ def set_client (self , client : redis .Redis , ** kwargs ):
358
365
"""Manually set the Redis client to use with the search index.
359
366
360
367
This method configures the search index to use a specific Redis or
@@ -729,10 +736,12 @@ def connect(self, redis_url: Optional[str] = None, **kwargs):
729
736
index.connect(redis_url="redis://localhost:6379")
730
737
731
738
"""
732
- client = RedisConnectionFactory .connect (redis_url , use_async = True , ** kwargs )
739
+ client = RedisConnectionFactory .connect (
740
+ redis_url = redis_url , use_async = True , ** kwargs
741
+ )
733
742
return self .set_client (client )
734
743
735
- @check_async_modules_present ()
744
+ @setup_async_redis ()
736
745
def set_client (self , client : aredis .Redis ):
737
746
"""Manually set the Redis client to use with the search index.
738
747
0 commit comments