OnHandCache
Constructors
Functions
External read — always returns a flow. If the key has no entry (or has expired), an empty flow (holding null) is created so subscribers can attach and be notified when a future set populates it. Also ensures a mutex exists for this key.
Internal nullable read — returns null if no entry exists or if the entry has expired, without creating one.
Non-suspend observation. Returns a cold Flow that, when collected, suspends to ensure the underlying MutableStateFlow exists and forwards its emissions. Useful for property initialization where we can't call the suspend get.
Thread-safe write. Ensures a mutex and flow exist, then emits under the per-key lock.
Convenience: write with optional TTL. Delegates to set or setWithTtl.
Thread-safe write with TTL. The entry will be evicted on the next read after ttl has elapsed since this write.
Run the action as a transaction, first performing updates. If action doesn't succeed, perform a rollback of all the values of the given keys. The caller MUST use setUnsafe() internally since we already hold the per-key mutexes — calling set() would deadlock.