in src/aws_encryption_sdk_cli/internal/arg_parsing.py [0:0]
def _process_caching_config(raw_caching_config):
# type: (RAW_CONFIG) -> CACHING_CONFIG
"""Applies additional processing to prepare the caching configuration.
:param list raw_caching_config: Unprocessed caching configuration
:returns: Processed caching configuration
:rtype: dict
:raises ParameterParseError: if invalid parameter name is found
:raises ParameterParseError: if either capacity or max_age are not defined
"""
_cast_types = {"capacity": int, "max_messages_encrypted": int, "max_bytes_encrypted": int, "max_age": float}
parsed_config = _parse_and_collapse_config(raw_caching_config)
if "capacity" not in parsed_config or "max_age" not in parsed_config:
raise ParameterParseError('If enabling caching, both "capacity" and "max_age" are required')
caching_config = {} # type: Dict[str, Union[str, int, float]]
for key, value in parsed_config.items():
try:
caching_config[key] = _cast_types[key](value)
except KeyError:
raise ParameterParseError('Invalid caching configuration key: "{}"'.format(key))
return caching_config