On 19.10.2018 06:33, HENG wrote:
Hello:
I am new to Nginx NJS, and I want to write a website with NJS.
I want to write a simple JSON database with NJS fs.writeFileSync ,just
like Node.js LowDB.
but I have no idea . Does NJS fs.writeFileSync is atomic writing and
race condition prevention ?
http://hg.nginx.org/njs/file/tip/njs/njs_fs.c#l649
It simply opens the file, makes several write syscalls into it, and
closes the file.
So, it is not atomic.
Probably we need here something like
https://www.npmjs.com/package/write-file-atomic
If NJS fs.writeFileSync is NOT atomic writing, it can NOT be treate as a
normal database file write.
Thank you !
--
--------------------------------------------------------------------
Heng
---------------------------------------------------------------------
--
_______________________________________________
nginx-devel mailing list
nginx-de...@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx