If I use CacheStorage.open()
to get the same Cache
in the UI thread as in a Worker thread, and begin reading/writing from/to it on both sides, is it safe? Or can there be race conditions? I'm hoping the Cache API is thread safe (I would assume that it is, like all else in JS).
Are JavaScript browser Cache objects made by CacheStorage threadsafe?
235 Views Asked by trusktr At
1
Yes. All methods return Promises, as the Cache might be managed by another thread, the Promise then resolves if the other thread performed the operation. There cannot be concurrent modifications or other such weird things.
Whenever there are multiple threads there can be race conditions, thats in the nature of things. That means that if you
add()
a cache entry while trying to retrieve it wothget()
from another WebWorker in parallel might or might not get you a result.