Skip to content

Optionally cache writes

James requested to merge jf/cached-writes into master

What

Adds an option to opt-in to caching writes which can lead to better performance but won't be applicable in cases where the read and the write are different streams or if there's some kind of validation logic in the read.

Why

By default Z was caching writes. But that assumes all write values are valid. There are some instances where the read option has valid logic that rejects the writes.

It is faster to cache writes, but if there's validation logic, the cached value should be evaluated after setting the value.

How to test

Tests added to the suite.

Questions

The PR opts for correctness over performance. By default, the cache will be recomputed after the write. But if you want to speed things up and you trust all writes, you can optionally enable this.

Maybe one day we'll flip this switch the other way by default and opt for performance instead of correctness, as for most state management in how.js will probably trust writes.

Fixes

Fixes #17 (closed)

Merge request reports