Skip to content

Commit dfa44dd

Browse files
committed
connections: add redis_url alias to _get_aredis_connection and update AsyncSearchIndex callers; tests: fix schema prefix typo
1 parent aa4c832 commit dfa44dd

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

redisvl/index/index.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ async def from_existing(
11951195

11961196
if redis_url:
11971197
redis_client = await RedisConnectionFactory._get_aredis_connection(
1198-
url=redis_url,
1198+
redis_url=redis_url,
11991199
**kwargs,
12001200
)
12011201
elif redis_client:
@@ -1229,7 +1229,7 @@ async def connect(self, redis_url: Optional[str] = None, **kwargs):
12291229
DeprecationWarning,
12301230
)
12311231
client = await RedisConnectionFactory._get_aredis_connection(
1232-
url=redis_url, **kwargs
1232+
redis_url=redis_url, **kwargs
12331233
)
12341234
await self.set_client(client)
12351235

@@ -1254,7 +1254,7 @@ async def _get_client(self) -> AsyncRedisClient:
12541254
# Pass lib_name to connection factory
12551255
kwargs = {**self._connection_kwargs}
12561256
if self._redis_url:
1257-
kwargs["url"] = self._redis_url
1257+
kwargs["redis_url"] = self._redis_url
12581258
if self._lib_name:
12591259
kwargs["lib_name"] = self._lib_name
12601260
self._redis_client = (

redisvl/redis/connection.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def get_redis_connection(
386386
@staticmethod
387387
async def _get_aredis_connection(
388388
url: Optional[str] = None,
389+
redis_url: Optional[str] = None,
389390
**kwargs,
390391
) -> AsyncRedisClient:
391392
"""Creates and returns an asynchronous Redis client.
@@ -394,8 +395,9 @@ async def _get_aredis_connection(
394395
only used internally by the library now.
395396
396397
Args:
397-
url (Optional[str]): The URL of the Redis server. If not provided,
398-
the environment variable REDIS_URL is used.
398+
url (Optional[str]): The URL of the Redis server.
399+
redis_url (Optional[str]): Alias for url for consistency with public APIs.
400+
If neither is provided, the environment variable REDIS_URL is used.
399401
**kwargs: Additional keyword arguments to be passed to the async
400402
Redis client constructor.
401403
@@ -406,7 +408,7 @@ async def _get_aredis_connection(
406408
ValueError: If url is not provided and REDIS_URL environment
407409
variable is not set.
408410
"""
409-
url = url or get_address_from_env()
411+
url = url or redis_url or get_address_from_env()
410412

411413
client: AsyncRedisClient
412414
if url.startswith("redis+sentinel"):

tests/unit/test_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def test_schema_serialization_with_new_attributes():
252252
original_schema_dict = {
253253
"index": {
254254
"name": "test-serialization",
255-
"prefix": "ser",
255+
"prefix": "set",
256256
"storage_type": "hash",
257257
},
258258
"fields": [

0 commit comments

Comments
 (0)