From 9ae434cfa1469f5c1aba4872e6861d3993b1ecf3 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Wed, 6 Sep 2023 22:49:03 +0000 Subject: [PATCH] added constant for cache size --- google/api_core/gapic_v1/routing_header.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/google/api_core/gapic_v1/routing_header.py b/google/api_core/gapic_v1/routing_header.py index 25559cfc..a3a2205b 100644 --- a/google/api_core/gapic_v1/routing_header.py +++ b/google/api_core/gapic_v1/routing_header.py @@ -25,6 +25,8 @@ from urllib.parse import urlencode ROUTING_METADATA_KEY = "x-goog-request-params" +# use caching to avoid repeated computation +ROUTING_PARAM_CACHE_SIZE = 32 def to_routing_header(params, qualified_enums=True): @@ -54,7 +56,7 @@ def to_routing_header(params, qualified_enums=True): ) -@functools.lru_cache(32) +@functools.lru_cache(ROUTING_PARAM_CACHE_SIZE) def to_grpc_metadata(params, qualified_enums=True): """Returns the gRPC metadata containing the routing headers for the given request parameters.