Skip to content

Commit 4ba9aa6

Browse files
Copilotmykaul
andcommitted
Use constants for TLS session cache default values
Define _DEFAULT_TLS_SESSION_CACHE_SIZE and _DEFAULT_TLS_SESSION_CACHE_TTL constants to avoid duplicating default values in multiple places. This makes it easier to maintain and change these defaults in the future. The constants are now used in: - Class attribute definitions - __init__ method signature defaults Co-authored-by: mykaul <[email protected]>
1 parent 57a5895 commit 4ba9aa6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cassandra/cluster.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ def _connection_reduce_fn(val,import_fn):
195195

196196
_NOT_SET = object()
197197

198+
# TLS session cache defaults
199+
_DEFAULT_TLS_SESSION_CACHE_SIZE = 100
200+
_DEFAULT_TLS_SESSION_CACHE_TTL = 3600 # 1 hour in seconds
201+
198202

199203
class NoHostAvailable(Exception):
200204
"""
@@ -886,7 +890,7 @@ def default_retry_policy(self, policy):
886890
.. versionadded:: 3.30.0
887891
"""
888892

889-
tls_session_cache_size = 100
893+
tls_session_cache_size = _DEFAULT_TLS_SESSION_CACHE_SIZE
890894
"""
891895
Maximum number of TLS sessions to cache. When the cache is full, the least
892896
recently used session is evicted.
@@ -896,7 +900,7 @@ def default_retry_policy(self, policy):
896900
.. versionadded:: 3.30.0
897901
"""
898902

899-
tls_session_cache_ttl = 3600
903+
tls_session_cache_ttl = _DEFAULT_TLS_SESSION_CACHE_TTL
900904
"""
901905
Time-to-live for cached TLS sessions in seconds. Sessions older than this
902906
are not reused and are removed from the cache.
@@ -1236,8 +1240,8 @@ def __init__(self,
12361240
no_compact=False,
12371241
ssl_context=None,
12381242
tls_session_cache_enabled=True,
1239-
tls_session_cache_size=100,
1240-
tls_session_cache_ttl=3600,
1243+
tls_session_cache_size=_DEFAULT_TLS_SESSION_CACHE_SIZE,
1244+
tls_session_cache_ttl=_DEFAULT_TLS_SESSION_CACHE_TTL,
12411245
endpoint_factory=None,
12421246
application_name=None,
12431247
application_version=None,

0 commit comments

Comments
 (0)