Raxol.UI.Rendering.ComponentCache (Raxol v2.0.1)

View Source

High-performance cache for component rendering results.

This module caches rendered component output to avoid redundant rendering of unchanged components. It tracks component props, state, and theme to invalidate cache when inputs change.

Features

  • Caches rendered cell output for components
  • Smart invalidation based on props/state changes
  • Integrates with ETS cache manager for performance
  • Telemetry instrumentation for monitoring
  • Supports partial rendering and dirty region tracking

Performance Impact

Expected improvements:

  • 50-70% reduction in rendering overhead for static components
  • Sub-millisecond access for cached renders
  • Reduced CPU usage during UI updates

Summary

Functions

Creates a unique cache key for a component based on its type, props, state, and theme.

Caches a partial render result for a specific region. Useful for virtualized lists and scrollable areas.

Gets a cached partial render for a region.

Gets cache statistics.

Invalidates all cached renders.

Invalidates cache for a specific component type.

Renders a component using cache when possible. Falls back to actual rendering if cache miss or invalidated.

Renders multiple elements with batched cache lookups.

Warms up cache with common component patterns.

Checks if a render would be cached (for debugging).

Functions

build_cache_key(component_type, props, state, theme_id)

Creates a unique cache key for a component based on its type, props, state, and theme.

cache_partial_render(region_id, bounds, cells)

Caches a partial render result for a specific region. Useful for virtualized lists and scrollable areas.

get_partial_render(region_id, bounds)

Gets a cached partial render for a region.

get_stats()

Gets cache statistics.

invalidate_all()

Invalidates all cached renders.

invalidate_component_type(component_type)

Invalidates cache for a specific component type.

render_cached(element, theme, parent_style \\ %{})

Renders a component using cache when possible. Falls back to actual rendering if cache miss or invalidated.

render_elements_cached(elements, theme)

Renders multiple elements with batched cache lookups.

warmup()

Warms up cache with common component patterns.

would_cache?(element, theme, parent_style)

Checks if a render would be cached (for debugging).