Skip to content

Commit

Permalink
added constant for cache size
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche authored Sep 6, 2023
1 parent 30189ea commit 9ae434c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion google/api_core/gapic_v1/routing_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9ae434c

Please sign in to comment.