core.cache.debug

Functions

_decode(→ str)

_describe(→ tuple[str, str])

analyze_cache_queries(→ collections.abc.Iterator[None])

Analyzes the redis commands executed during its context.

Module Contents

core.cache.debug._decode(value: Any) str[source]
core.cache.debug._describe(args: tuple[Any, ...]) tuple[str, str][source]
core.cache.debug.analyze_cache_queries(report: Literal['summary', 'redundant', 'all'] = 'summary') collections.abc.Iterator[None][source]

Analyzes the redis commands executed during its context. Mirrors onegov.core.orm.debug.analyze_sql_queries(). There are three levels of information (report argument):

  • ‘summary’ (only show the number of commands)

  • ‘redundant’ (show summary and the keys hit more than once)

  • ‘all’ (show summary and every command)

Unlike hooking our RedisCacheRegion, this counts the actual commands sent to redis, so cache layers that avoid a round-trip (e.g. the request/schema caches in front of orm_cached()) don’t inflate the numbers. Only two methods need hooking regardless of how the dogpile API evolves.

Use this with a with-statement:

with analyze_cache_queries():
    ...  # <- analyzes all redis commands that happen inside here