You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specifically, how to handle cacha.get when the file is still open for write via cacha.set in a separate process.
I am not sure exactly how Node behaves in this scenario (hopefully it just returns / throws an error). If that's the case, maybe just a delay / retry loop.
Alternatively (but more complicated, and I'm still not 100% sure how it would look); Have it write to a temp file, then rename. I think renames are atomic cross-platform.
I think we are mostly safe on this since the file name is the hash of the contents.
That prevents us from having to decide who "wins" in a race condition for writes (if a race condition for the same filename exists, it doesn't matter who wins - they are both trying to write the same contents).
The issue is mostly how to handle reads while the file is write-locked.
The text was updated successfully, but these errors were encountered:
We need this to work across multiple process.
Specifically, how to handle
cacha.get
when the file is still open for write viacacha.set
in a separate process.I am not sure exactly how Node behaves in this scenario (hopefully it just returns / throws an error). If that's the case, maybe just a delay / retry loop.
Alternatively (but more complicated, and I'm still not 100% sure how it would look); Have it write to a temp file, then rename. I think renames are atomic cross-platform.
Windows: how to do atomic writes in a file
Things UNIX can do atomically
I think we are mostly safe on this since the file name is the hash of the contents.
That prevents us from having to decide who "wins" in a race condition for writes (if a race condition for the same filename exists, it doesn't matter who wins - they are both trying to write the same contents).
The issue is mostly how to handle reads while the file is write-locked.
The text was updated successfully, but these errors were encountered: