> For the complete documentation index, see [llms.txt](https://docs.origami.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.origami.tech/reference/grid-language/functions/cached.md).

# cached()

cached() stores the result of a formula for a set time-to-live, per order or per grid, to avoid recalculating it on every cycle.

Understand how the Cached function in Origami Tech temporarily stores computed data to reduce recalculation time and optimize strategy performance.

## `cached`(*ttl*: *int*, *respect*: *str* =’*order\_pos*’)(*cached\_value*: *str*)

Function that is typically used for caching equitation results of `cached_value` formula.

`cached_value` string representation is used as a key for cache

`ttl` positive integer which is defines time-to-live for cache

`respect` one of (default `order_pos`):

* `order_pos` - calculate `cached_value` for each order in grid
* `grid` - calculate `cached_value` for the whole grid
* `bot` - calculate `cached_value` for the whole bot
* `global` - calculate `cached_value` . Results are used for all bots

{% hint style="warning" %}
\`respect=”order\_pos”\` must not be used with \`update\_balance\_formula\` inside group and bot
{% endhint %}

{% hint style="warning" %}
\`respect=”grid”\` must not be used with \`update\_balance\_formula\` inside group and bot
{% endhint %}

{% hint style="warning" %}
\`respect=”bot”\` must not be used with \`update\_balance\_formula\` inside group
{% endhint %}

`respect='order_pos'` orders are the same during `ttl` seconds

`respect='grid'` all orders are placed with the same inside one grid during `ttl` seconds

{% hint style="warning" %}
Grids must exist to use this type of cache due to the need to get the `grid.id`
{% endhint %}

but the price changes between grids

`respect='bot'` all orders are placed with the same over the all grids in one bot during `ttl` seconds \*Warning: bot must exist to use this type of cache due to the need to get the `bot.id`

`respect='global'` all orders are placed with the same over the all bots during `ttl` seconds

Example:
