The small cache service below reads and updates data for a single key. The behavior should be deterministic for sequential calls and for concurrent updates from different Futures.
upsert must store the new value in the cache and return the stored value.getOrLoad must return an already stored value if it exists.getOrLoad must call load exactly once, store the result, and return it.ExecutionContext.global and must not depend on the completion order of individual tasks.CacheStore.upsert("k", "v1"), then immediately getOrLoad("k", ...).getOrLoad("missing", ...) calls with the same key and different delays in load.upsert, reading the same key returns the new value.load is propagated to the caller.scala-cli test . or equivalent compilation/run in one processExecutionContext: ExecutionContext.globalUse line comments to explain the problem, its impact, the fix and how to test it.