11import os
2- from dataclasses import dataclass
32from typing import Any , Dict , List , Optional , Tuple , Type , TypeVar , Union , overload
43from urllib .parse import parse_qs , urlencode , urlparse , urlunparse
54from warnings import warn
2322)
2423from redisvl .redis .utils import convert_bytes , is_cluster_url
2524from redisvl .types import AsyncRedisClient , RedisClient , SyncRedisClient
25+ from redisvl .utils .log import get_logger
2626from redisvl .utils .utils import deprecated_function
2727
28+ logger = get_logger (__name__ )
29+
2830
2931def _strip_cluster_from_url_and_kwargs (
3032 url : str , ** kwargs
@@ -499,7 +501,6 @@ def get_redis_connection(
499501
500502 @staticmethod
501503 async def _get_aredis_connection (
502- url : Optional [str ] = None ,
503504 redis_url : Optional [str ] = None ,
504505 ** kwargs ,
505506 ) -> AsyncRedisClient :
@@ -509,9 +510,11 @@ async def _get_aredis_connection(
509510 only used internally by the library now.
510511
511512 Args:
512- url (Optional[str]): The URL of the Redis server.
513- redis_url (Optional[str]): Alias for url for consistency with public APIs.
514- If neither is provided, the environment variable REDIS_URL is used.
513+ redis_url (Optional[str]): The URL of the Redis server. If neither
514+ `redis_url` nor `url` are provided, the environment variable
515+ REDIS_URL is used.
516+ url (Optional[str]): Former parameter for the URL of the Redis
517+ server. Use `redis_url` instead. (Deprecated)
515518 **kwargs: Additional keyword arguments to be passed to the async
516519 Redis client constructor.
517520
@@ -522,7 +525,13 @@ async def _get_aredis_connection(
522525 ValueError: If url is not provided and REDIS_URL environment
523526 variable is not set.
524527 """
525- url = url or redis_url or get_address_from_env ()
528+ _deprecated_url = kwargs .pop ("url" , None )
529+ url = _deprecated_url or redis_url or get_address_from_env ()
530+
531+ if _deprecated_url is not None :
532+ logger .warning (
533+ "The `url` parameter is deprecated. Please use `redis_url` instead."
534+ )
526535
527536 client : AsyncRedisClient
528537 if url .startswith ("redis+sentinel" ):
@@ -555,14 +564,17 @@ async def _get_aredis_connection(
555564
556565 @staticmethod
557566 def get_async_redis_connection (
558- url : Optional [str ] = None ,
567+ redis_url : Optional [str ] = None ,
559568 ** kwargs ,
560569 ) -> AsyncRedisClient :
561570 """Creates and returns an asynchronous Redis client.
562571
563572 Args:
564- url (Optional[str]): The URL of the Redis server. If not provided,
565- the environment variable REDIS_URL is used.
573+ redis_url (Optional[str]): The URL of the Redis server. If neither
574+ `redis_url` nor `url` are provided, the environment variable
575+ REDIS_URL is used.
576+ url (Optional[str]): Former parameter for the URL of the Redis
577+ server. Use `redis_url` instead. (Deprecated)
566578 **kwargs: Additional keyword arguments to be passed to the async
567579 Redis client constructor.
568580
@@ -577,7 +589,12 @@ def get_async_redis_connection(
577589 "get_async_redis_connection will become async in the next major release." ,
578590 DeprecationWarning ,
579591 )
580- url = url or get_address_from_env ()
592+ _deprecated_url = kwargs .pop ("url" , None )
593+ url = _deprecated_url or redis_url or get_address_from_env ()
594+ if _deprecated_url is not None :
595+ logger .warning (
596+ "The `url` parameter is deprecated. Please use `redis_url` instead."
597+ )
581598
582599 if url .startswith ("redis+sentinel" ):
583600 return RedisConnectionFactory ._redis_sentinel_client (
0 commit comments