Module

cache.query_index_registry

Query Index Registry - Manages all query indexes.

Coordinates:

  • Index registration (built-in + custom)
  • Index building (full + incremental)
  • Index persistence
  • Template access

Architecture:

  • Lazy initialization (only load when needed)
  • Automatic built-in registration
  • Support for custom user indexes
  • Incremental updates with dependency tracking

Classes

QueryIndexRegistry
Registry for all query indexes. Manages the lifecycle of query indexes: - Registration (built-in +…
12

Registry for all query indexes.

Manages the lifecycle of query indexes:

  • Registration (built-in + custom)
  • Building (full + incremental)
  • Persistence
  • Template access via site.indexes

Methods 7

register
Register a query index.
2 None
def register(self, name: str, index: QueryIndex) -> None

Register a query index.

Parameters 2
name str

Index name (e.g., 'section', 'author', 'status')

index QueryIndex

QueryIndex instance

build_all
Build all indexes from scratch (full build).
3 None
def build_all(self, pages: list[Page], build_cache: BuildCache, skip_generated: bool = True) -> None

Build all indexes from scratch (full build).

Parameters 3
pages list[Page]

All site pages

build_cache BuildCache

Build cache for dependency tracking

skip_generated bool

Skip generated pages (tag pages, etc.)

update_incremental
Update indexes incrementally for changed pages.
3 dict[str, set[str]]
def update_incremental(self, changed_pages: list[Page], build_cache: BuildCache, skip_generated: bool = True) -> dict[str, set[str]]

Update indexes incrementally for changed pages.

Parameters 3
changed_pages list[Page]

Pages that changed

build_cache BuildCache

Build cache for dependency tracking

skip_generated bool

Skip generated pages

Returns

dict[str, set[str]]

Dict mapping index_name → affected_keys

get
Get index by name.
1 QueryIndex | None
def get(self, index_name: str) -> QueryIndex | None

Get index by name.

Parameters 1
index_name str

Index name (e.g., 'section', 'author')

Returns

QueryIndex | None

QueryIndex instance or None if not found

has
Check if index exists.
1 bool
def has(self, index_name: str) -> bool

Check if index exists.

Parameters 1
index_name str

Index name

Returns

bool

True if index is registered

save_all
Save all indexes to disk.
0 None
def save_all(self) -> None

Save all indexes to disk.

stats
Get statistics for all indexes.
0 dict[str, Any]
def stats(self) -> dict[str, Any]

Get statistics for all indexes.

Returns

dict[str, Any]

Dict with index stats

Internal Methods 5
__init__
Initialize registry.
2 None
def __init__(self, site: Site, cache_dir: Path)

Initialize registry.

Parameters 2
site Site

Site instance

cache_dir Path

Directory for index cache files

_ensure_initialized
Lazy initialization - only register indexes when first accessed.
0 None
def _ensure_initialized(self) -> None

Lazy initialization - only register indexes when first accessed.

_register_builtins
Register built-in indexes.
0 None
def _register_builtins(self) -> None

Register built-in indexes.

__getattr__
Allow attribute-style access: registry.section instead of registry.get('section').
1 QueryIndex
def __getattr__(self, name: str) -> QueryIndex

Allow attribute-style access: registry.section instead of registry.get('section').

Parameters 1
name str

Index name

Returns

QueryIndex

QueryIndex instance

__repr__
String representation.
0 str
def __repr__(self) -> str

String representation.

Returns

str