reactive-python / reactpy-django

It's React, but in Python. Now with Django integration.
https://reactive-python.github.io/reactpy-django/
MIT License
322 stars 18 forks source link

Add a cache decorator #192

Closed Archmonger closed 6 months ago

Archmonger commented 11 months ago

Current Situation

We currently don't have any multiprocessing compatible way to cache component renders, similar to Django's cached_page decorator.

Proposed Actions

Create a caching decorator. The API might look something like this....

def cache_component(timeout, *, cache=None):
    """The cache is keyed by the component's dotted path."""
    ...
    return decorator

@cache_component(60 * 15, cache=REACTPY_CACHE)
@component
def example():
   ...
Archmonger commented 6 months ago

Closing this since it is not technologically possible to maintain interactivity while also catching renders.