From c6477861ecc5b359c108a994a397df8c49da4c13 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Fri, 28 Jun 2024 00:14:27 +0000 Subject: [PATCH] Fix our cache key generation when involving API clients. --- bemani/data/api/client.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bemani/data/api/client.py b/bemani/data/api/client.py index bbb1423..61f2f9b 100644 --- a/bemani/data/api/client.py +++ b/bemani/data/api/client.py @@ -54,15 +54,20 @@ class APIClient: def __repr__(self) -> str: # Specifically defined so that two different instances of the same API client # cache under the same key, as we want to share results from a given server - # to all local requests. - return ( + # to all local requests. We also have to be sensitive to any control character + # limitations for memcached. + repr_val = ( "APIClient(" - + f"base_uri={self.base_uri!r}, " - + f"token={self.token!r}, " - + f"allow_stats={self.allow_stats!r}, " + + f"base_uri={self.base_uri!r}," + + f"token={self.token!r}," + + f"allow_stats={self.allow_stats!r}," + f"allow_scores={self.allow_scores!r}" + ")" ) + repr_val = repr_val.replace(" ", "_") + repr_val = repr_val.replace("\r", "_") + repr_val = repr_val.replace("\n", "_") + return repr_val def _content_type_valid(self, content_type: str) -> bool: if ";" in content_type: