# transaction cache statement

The transaction cache statement enables
or disables the transaction read cache.

## Syntax

```
transaction cache [on|off|exp]
```

## Parameter(s)

| on | Enables the transaction read cache. |
| --- | --- |
| off | Disables the transaction read cache. |
| exp | The transaction read cache is turned on if the expression evaluates to nonzero (true) and turned off if it evaluates to 0 (false). |

## Description

Normally, all read operations
within a transaction first query the list of uncommitted updates.
This allows the re-reading of an item already written.

Users
can turn this cache off if they are confident that the transaction
does not attempt this activity. Turning the cache off can improve
the performance of reads within a transaction, especially if the transaction
is particularly long.

Once the cache is turned off, it remains
off until the program completes.

## Example(s)

```
transaction start
transaction cache on else msg="6 cache"; goto fail
write "1" on "1"
read xx from "1" else msg="6 read"; goto fail
transaction rollback
read xx from "1" then msg="6 read2"; goto fail
delete 1
transaction start
transaction cache off else msg="7 cache"; goto fail
write "1" on "1"
read xx from "1" then msg="7 read"; goto fail
transaction commit
read xx from "1" else msg="7 read2"; goto fail
delete 1
```

## See also

- [begin work statement](https://d3codex.com/pickbasic-flashbasic/begin-work-statement/)

---
Source: https://d3codex.com/pickbasic-flashbasic/transaction-cache-statement/ - part of the D3Codex reference.
