用于Pi Zero的DB运行多个NodeJ进程 [英] DB for Pi Zero running multiple NodeJs processes

查看:73
本文介绍了用于Pi Zero的DB运行多个NodeJ进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在pi零上有一个本地数据库,其中有多个正在运行的进程需要写入和读取数据。 SQLite这样的规则(我认为)。根据我的经验,SQLite一次仅允许一个连接,并且在尝试执行数据库工作的多个进程中比较棘手。我所有的数据传输都是由JSON驱动的,因此NOSQL有意义,但是我需要一些重量轻的东西来存储一些配置并存储将同步到服务器的数据。但是,什么样的NOSQL选项最适合在具有NODE支持的pi上运行?

I need a local DB on a pi zero, with multiple processes running that need to write and read data. That kind of rules SQLite out (I think). From my experience SQLite only allows one connection at a time and is tricky with multiple processes trying to do database work. All of my data transmission would be JSON driven so NOSQL makes sense but I need something light weight to store a few configs and to store data that will synced up to the server. But what NOSQL options would be best to run on a pi with great NODE support?

推荐答案

SQLite通常与多个并发进程。从SQLite常见问题解答中:

SQLite is generally fine when using it with multiple concurrent processes. From the SQLite FAQ:


我们知道没有其他嵌入式SQL数据库引擎支持与SQLite一样多的并发性。 SQLite允许多个进程一次打开数据库文件,并允许多个进程一次读取数据库。当任何进程要写入时,它必须在更新期间锁定整个数据库文件。但这通常只需要几毫秒。其他过程只是等待作者完成,然后继续其业务。其他嵌入式SQL数据库引擎通常只允许单个进程一次连接到数据库。

We are aware of no other embedded SQL database engine that supports as much concurrency as SQLite. SQLite allows multiple processes to have the database file open at once, and for multiple processes to read the database at once. When any process wants to write, it must lock the entire database file for the duration of its update. But that normally only takes a few milliseconds. Other processes just wait on the writer to finish then continue about their business. Other embedded SQL database engines typically only allow a single process to connect to the database at once.

对于大多数应用程序,应该没事的。如果您的进程中只有一个正在执行写操作,而另一个仅在执行读操作,那么它应该根本没有影响。

For the majority of applications, that should be fine. If only one of your processes is doing writes, and the other only reads, it should have no impact at all.

如果您正在寻找特定于NoSQL的内容,您还可以考虑在Google Chrome浏览器中使用的 LevelDB 。使用Node,最好的方法是通过 levelup 库。

If you're looking for something that's NoSQL-specific, you can also consider LevelDB, which is used in Google Chrome. With Node, the best way to access it is through the levelup library.

这篇关于用于Pi Zero的DB运行多个NodeJ进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆