Clarify unix.mapshared versus file locks

This commit is contained in:
Björn Buckwalter 2025-01-21 12:54:06 +01:00 committed by GitHub
parent 9f6bf6ea71
commit 5223907686
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4864,9 +4864,9 @@ UNIX MODULE
end end
It's possible to accomplish the same thing as unix.mapshared() It's possible to accomplish the same thing as unix.mapshared()
using files and unix.fcntl() advisory locks. However this goes using files and unix.fcntl() advisory locks. For example, that's
significantly faster. For example, that's what SQLite does and what SQLite does and we recommend using SQLite for IPC in redbean.
we recommend using SQLite for IPC in redbean. But, if your app However, unix.mapshared is significantly faster and if your app
has thousands of forked processes fighting for a file lock you has thousands of forked processes fighting for a file lock you
might need something lower level than file locks, to implement might need something lower level than file locks, to implement
things like throttling. Shared memory is a good way to do that things like throttling. Shared memory is a good way to do that