cached

To run a given script only once and cache and return the output value

This function allows you to cache calculations of an elaborate script during the first execution. Instead of a new calculation, the saved value is then returned.

But if you want to trigger a recalculation of your script, you have the following options:

  • Execute the invalidate() function in any table of your database

This feature can help solve performance problems.

Learn more about Optimizing scripts

Syntax

cached(script)

Return

any

Examples

let cache := cached(
    let user := user();
    select Tasks where 'Due Date' > today() and 'Assigned user'.'Ninox user' = user
);
cache

Result: The records from the Tasks table that are still open and assigned to the current user are cached and returned.

See also

invalidate, which clears the cache of the database and the values stored by cached().

Last updated