> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revoengine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# api.compareAndSetInstanceCache()

> Public low-code contract, signatures and examples for api.compareAndSetInstanceCache.

## `api.compareAndSetInstanceCache()`

Atomically updates a cache key only when the current value matches 'expected'.

Notes:

* Unavailable with `readOnly: true` (throws an error).

### Signature

```ts theme={null}
static compareAndSetInstanceCache(
      key: string,
      expected: any,
      value: any,
      seconds?: number,
    ): Promise<boolean>;
```

### Example

```ts theme={null}
const swapped = await api.compareAndSetInstanceCache('sync:state', { step: 'queued' }, { step: 'running' }, 300);
```

See [all api methods](https://docs.revoengine.com/low-code/reference/api.md) or [runtime basics](https://docs.revoengine.com/low-code/overview.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.