You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/sdk/README.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,3 +23,18 @@ cached for later calls. A mismatch throws `SubRosaNetworkMismatchError` before
23
23
simulation, signing, or submission, with the conflicting values and a suggested
24
24
fix. Contract IDs do not encode a Stellar network, so copying a `C...` address
25
25
between Testnet and Mainnet requires updating all three configuration values.
26
+
27
+
## Caching
28
+
29
+
You can optionally configure a short-lived cache for `getRound` and `getConfig` reads by providing a `cacheTtl` (in milliseconds):
30
+
31
+
```ts
32
+
const client =newSubRosaClient({
33
+
// ... other config
34
+
cacheTtl: 5000, // 5 seconds
35
+
});
36
+
```
37
+
38
+
This reduces avoidable RPC load and latency when dashboards or keeper watch loops re-read the same round repeatedly.
39
+
40
+
**Tradeoffs**: Reads may be stale for up to `cacheTtl` milliseconds if another client updates the round. However, the client automatically invalidates its own cache for a round when it successfully executes a state-changing write operation (e.g., `commit`, `reveal`, `settle`) for that round.
0 commit comments