---
title: "cache"
description: "A Compose compiler plugin API. DO NOT call directly.

Cache, that is remember, a value in the composition data of a composition. This is used to
implement [remember] and used by the compiler plugin to generate more efficient calls to
[remember] when it determines these optimizations are safe."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
@ComposeCompilerApi
public inline fun <T> Composer.cache(invalid: Boolean, block: @DisallowComposableCalls () -> T): T
```


A Compose compiler plugin API. DO NOT call directly.

Cache, that is remember, a value in the composition data of a composition. This is used to
implement `remember` and used by the compiler plugin to generate more efficient calls to
`remember` when it determines these optimizations are safe.



