FormatOpt

class privex.helpers.decorators.FormatOpt(value)[source]

This enum represents various options available for r_cache() ‘s format_opt parameter.

To avoid bloating the PyDoc for r_cache too much, descriptions for each formatting option is available as a short PyDoc comment under each enum option.

Usage:

>>> @r_cache('mykey', format_args=[0, 'x'], format_opt=FormatOpt.POS_AUTO)
__init__()

Initialize self. See help(type(self)) for accurate signature.

Attributes

Attributes

KWARG_ONLY

Only use kwargs for formatting the cache key - requires named format placeholders, i.e. mykey:{x}.

MIX

Use both *args and **kwargs to format the cache_key (assuming mixed placeholders e.g.

POS_AUTO

First attempt to format using *args whitelisted in format_args, if that causes a KeyError/IndexError, then pass kwarg values in the order they’re listed in format_args (only includes kwarg names listed in format_args)

POS_ONLY

Only use positional args for formatting the cache key, kwargs will be ignored completely.