Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
Connection object to talk to redis.

It is not safe to pass PubSub or Pipeline objects between threads.

:param float idle_connection_timeout:
If set, connections that have been idle for longer than this timeout
(in seconds) will be automatically closed. If unset, idle connections
are never closed. This parameter is passed through to the connection pool
constructor, so it's only used when a connection_pool instance is not provided.
:param float idle_check_interval:
Minimum time between idle connection cleanup runs. Defaults to 60 seconds.
Only used when idle_connection_timeout is set. As with idle_connection_timeout,
this parameter is passed through to the connection pool constructor,
so it's only used when a connection_pool instance is not provided.
"""

@classmethod
Expand Down Expand Up @@ -250,6 +261,8 @@ def __init__(
cache_config: Optional[CacheConfig] = None,
event_dispatcher: Optional[EventDispatcher] = None,
maint_notifications_config: Optional[MaintNotificationsConfig] = None,
idle_connection_timeout: Optional[float] = None,
idle_check_interval: float = 60.0,
Comment on lines +264 to +265
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing documentation for new parameters. The idle_connection_timeout and idle_check_interval parameters are added to the __init__ method but are not documented in the docstring. These parameters should be documented in the Args section to help users understand their purpose and usage.

Consider adding documentation like:

idle_connection_timeout:
    If set, connections that have been idle (not used) for longer than
    this timeout (in seconds) will be automatically closed. If None (default),
    idle connections are never closed. Only used when connection_pool is not provided.
idle_check_interval:
    How frequently (in seconds) to check for idle connections. Defaults to 60 seconds.
    Only used when idle_connection_timeout is set and connection_pool is not provided.

Copilot uses AI. Check for mistakes.
) -> None:
"""
Initialize a new Redis client.
Expand Down Expand Up @@ -314,6 +327,8 @@ def __init__(
"redis_connect_func": redis_connect_func,
"credential_provider": credential_provider,
"protocol": protocol,
"idle_connection_timeout": idle_connection_timeout,
"idle_check_interval": idle_check_interval,
}
# based on input, setup appropriate connection args
if unix_socket_path is not None:
Expand Down
2 changes: 2 additions & 0 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def parse_cluster_myshardid(resp, **options):
"username",
"cache",
"cache_config",
"idle_connection_timeout",
"idle_check_interval",
)
KWARGS_DISABLED_KEYS = ("host", "port", "retry")

Expand Down
Loading