MPT Redis Parser¶
-
class
django_docker_helpers.config.backends.mpt_redis_parser.MPTRedisParser(scope=None, host='127.0.0.1', port=6379, db=0, path_separator='.', key_prefix='', object_deserialize_prefix='::YAML::\n', object_deserialize=<function default_yaml_object_deserialize>, **redis_options)[source]¶ Bases:
django_docker_helpers.config.backends.base.BaseParserMaterialized Path Tree Redis Parser.
Compared to, e.g.
RedisParserit does not load a whole config file from a single key, but reads every config option from a corresponding variable path.Example:
parser = MPTRedisParser(host=REDIS_HOST, port=REDIS_PORT) parser.get('nested.a.b') parser.get('debug')
If you want to store your config with separated key paths take
mp_serialize_dict()helper to materialize your dict.Parameters: - scope (
Optional[str]) – a global namespace-like variable prefix - host (
str) – redis host, default is'127.0.0.1' - port (
int) – redis port, default id6379 - db (
int) – redis database, default is0 - path_separator (
str) – specifies which character separates nested variables, default is'.' - key_prefix (
str) – prefix all keys with specified one - object_deserialize_prefix (
str) – if object has a specified prefix, it’s deserialized withobject_deserialize - object_deserialize (
Optional[Callable]) – deserializer for complex variables - redis_options – additional options for
redis.Redisclient
-
get(variable_path, default=None, coerce_type=None, coercer=None, **kwargs)[source]¶ Parameters: - variable_path (
str) – a delimiter-separated path to a nested value - default (
Optional[Any]) – default value if there’s no object by specified path - coerce_type (
Optional[Type[+CT_co]]) – cast a type of a value to a specified one - coercer (
Optional[Callable]) – perform a type casting with specified callback - kwargs – additional arguments inherited parser may need
Returns: value or default
- variable_path (
- scope (