# caching

URL: /kida/api/compiler/statements/caching/
Section: statements
Description: Caching and filter-block statement compilation for Kida compiler.

Provides mixin for compiling cache blocks and filter blocks -- both
follow the "capture output, transform, emit" pattern.

Extracted from special_blocks.py for module focus (RFC: compiler decomposition).
Uses inline TYPE_CHECKING declarations for host attributes.
See: plan/rfc-mixin-protocol-typing.md

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/compiler/statements/caching/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fstatements%2Fcaching%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fstatements%2Fcaching%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fstatements%2Fcaching%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fstatements%2Fcaching%2Findex.txt)

Module

#
`compiler.statements.caching`

Caching and filter-block statement compilation for Kida compiler.

Provides mixin for compiling cache blocks and filter blocks -- both
follow the "capture output, transform, emit" pattern.

Extracted from special_blocks.py for module focus (RFC: compiler decomposition).
Uses inline TYPE_CHECKING declarations for host attributes.
See: plan/rfc-mixin-protocol-typing.md

1Class

## Classes

`CachingMixin`

2

▼

Mixin for compiling cache and filter-block statements.

Host attributes and cross-mixin dependencie…

Mixin for compiling cache and filter-block statements.

Host attributes and cross-mixin dependencies are declared via inline
TYPE_CHECKING blocks.

#### Methods

Internal Methods
2

▼

`_compile_cache`

1

`list[ast.stmt]`

▼

Compile {% cache key %}...{% endcache %.

Fragment caching. In streaming mode: …

`def _compile_cache(self, node: Cache) -> list[ast.stmt]`

Compile {% cache key %}...{% endcache %.

Fragment caching. In streaming mode: collect into buffer, cache,
then yield. Body always uses StringBuilder mode for caching.

##### Parameters

Name
Type
Description

`node`
`—`

##### Returns

`list[ast.stmt]`

`_compile_filter_block`

1

`list[ast.stmt]`

▼

Compile {% filter name %}...{% endfilter %.

Apply a filter to an entire block …

`def _compile_filter_block(self, node: FilterBlock) -> list[ast.stmt]`

Compile {% filter name %}...{% endfilter %.

Apply a filter to an entire block of content.
In streaming mode: collect into buffer, apply filter, yield result.

##### Parameters

Name
Type
Description

`node`
`—`

##### Returns

`list[ast.stmt]`
