Cache expression – remembering a value for a while¶
The cache expression evaluates another expression once and hands out the stored result until it expires. It changes nothing about the value – only how often it is computed. Use it around expressions that are expensive or call other systems, when a slightly outdated value is acceptable.
1. At a glance¶
| Purpose | Stores the value of another expression for a number of minutes |
| Typical use | Entra profile pictures in grids and app bars, results of external HTTP calls, expensive sub queries |
| Returns | The value of the input expression, with its type |
| Related | Image, Sub Query |
2. Settings¶
| Setting | Meaning | Default |
|---|---|---|
| "Input" | The expression whose value is cached | – (required) |
| "Cache Key" | An expression whose result distinguishes the cached values. Every distinct key has its own value. | empty – one single value for the whole expression |
| "User Scoped" | Every user has a cache of their own | off – all users share the cache |
| "Expiration (Minutes)" | How long a value is kept before the input is evaluated again | 60; 0 or less switches caching off |
3. Behaviour¶
- nexxcite evaluates "Cache Key" and looks for a stored value for this expression, this key and – with "User Scoped" – this user.
- If a value is stored and has not expired, it is returned. "Input" is not evaluated.
-
Otherwise "Input" is evaluated, the result is stored and returned.
-
A change to the cache expression itself makes earlier stored values unusable; the next evaluation computes anew.
- The cache is kept in the memory of each server and is empty after a restart. With several servers, each server has its own cache, so two users can briefly see different values.
- In background processing without a signed-in user, "User Scoped" values are kept apart from all users.
Choosing the key and the scope¶
The two settings decide whether the cache is correct:
- "Cache Key" must contain everything the input depends on. A profile picture cached without the
user as key shows the first user's picture for everybody; a value per record needs the record id
(system function
EntitySetRecId) in the key. - "User Scoped" is required as soon as the input depends on who evaluates it – the current user, their permissions, what their queries return. A shared cache would show one user's result to the next. Leave it off when the value is the same for everybody; a shared cache saves the most work.
4. Example¶
Profile pictures in a grid: Input = an Image expression with the source
"Entra Profile Picture" and the user from the field "E-mail"; Cache Key = the field "E-mail";
User Scoped off; Expiration = 240. Each picture is read from Microsoft at most once every four
hours per server.
5. Limitations¶
- Do not cache values that must be current the moment they change – a status, a stock level, a permission check.
- There is no way to empty the cache by hand other than changing the expression or restarting the application.