podpac.utils.cached_propertyΒΆ

Decorator that creates a property that is cached.

keyword use_cache_ctrl

If True, the property is cached using the Node cache_ctrl. If False, the property is only cached as a private attribute. Default False.

kwtype use_cache_ctrl

bool

Notes

Podpac caching using the cache_ctrl will be unreliable if the property depends on any non-tagged traits. The property should only use node attrs (traits tagged with attr=True).

Examples

>>> class MyNode(Node):
    # property that is recomputed every time
    @property
    def my_property(self):
        return 0

# property is computed once for each object @cached_property def my_cached_property(self):

return 1

# property that is computed once and can be reused by other Nodes or sessions, depending on the cache_ctrl @cached_property(use_cache_ctrl=True) def my_persistent_cached_property(self):

return 2