Synchronous write for small values. Throws on codec failure, preserving the prior state. Prefer setAsync for expensive payloads; this method runs on the calling thread.
Compatibility overload: skips encoding equal values when distinct is true.