diff --git a/powerdns_api_proxy/config.py b/powerdns_api_proxy/config.py index 7a43959..006fe92 100644 --- a/powerdns_api_proxy/config.py +++ b/powerdns_api_proxy/config.py @@ -35,6 +35,7 @@ def load_config(path: Optional[Path] = None) -> ProxyConfig: return config +@lru_cache(maxsize=1000) def token_defined(config: ProxyConfig, token: str) -> bool: sha512 = hashlib.sha512() sha512.update(token.encode()) @@ -57,6 +58,7 @@ def dependency_check_token_defined( check_token_defined(load_config(), X_API_Key) +@lru_cache(maxsize=1000) def get_environment_for_token( config: ProxyConfig, token: str ) -> ProxyConfigEnvironment: diff --git a/powerdns_api_proxy/models.py b/powerdns_api_proxy/models.py index 751efcc..46a059e 100644 --- a/powerdns_api_proxy/models.py +++ b/powerdns_api_proxy/models.py @@ -133,6 +133,14 @@ def api_token_defined(cls, v): raise ValueError('pdns_api_token must a non-empty string') return v + def __hash__(self): + return hash( + self.pdns_api_url + + self.pdns_api_token + + str(self.pdns_api_verify_ssl) + + str(self.environments) + ) + class ResponseAllowed(BaseModel): zones: list[ProxyConfigZone]