简体   繁体   English

KyotoCabinet和多个进程?

[英]KyotoCabinet and multiple processes?

I've read the documentation and found very little about multiple processes (readers and writers) accessing a single kyotocabinet database. 我已经阅读了文档,但对访问单个kyocacabinet数据库的多个进程(读取器和写入器)的了解很少。 It appears you can create multiple readers, but unless you specify ONOLOCK multiple writers will block trying to open the db. 看来可以创建多个读取器,但是除非指定ONOLOCK,否则多个写入器将阻止尝试打开数据库。 Can anyone shed any light on how this works or if it is possible? 任何人都无法阐明其工作原理或是否可行? I understand KyotoTycoon is one option, but am curious specifically about KyotoCabinet. 我知道KyotoTycoon是一种选择,但是对KyotoCabinet特别好奇。

Found this on the tokyocabinet manpage: 在tokyocabinet联机帮助页上找到此内容:

Tokyo Cabinet provides two modes to connect to a database: "reader" and "writer". 东京内阁提供两种连接数据库的模式:“读取器”和“写入器”。 A reader can perform retrieving but neither storing nor deleting. 阅读器可以执行检索,但不能存储或删除。 A writer can perform all access methods. 编写者可以执行所有访问方法。 Exclusion control between processes is performed when connecting to a database by file locking. 通过文件锁定连接到数据库时,将执行进程之间的排除控制。 While a writer is connected to a database, neither readers nor writers can be connected. 当写入器连接到数据库时,读取器和写入器均无法连接。 While a reader is connected to a database, other readers can be connect, but writers can not. 当读取器连接到数据库时,可以连接其他读取器,但是写入器则不能。 According to this mechanism, data consistency is guaranteed with simultaneous connections in multitasking environment. 根据这种机制,在多任务环境中同时连接可以保证数据的一致性。

Guessing then, that this applies to kyoto as well. 然后猜测,这也适用于京都。

Kyoto Cabinet is thread safe, but you cannot have separate processes reading and writing at the same time. Kyoto Cabinet是线程安全的,但是您不能同时进行单独的读写过程。 You can have multiple reader processes as long as there is no writer connected. 只要没有写入器连接,就可以有多个读取器进程。

From the website : 网站

Sharing One database by Multiple Processes 通过多个进程共享一个数据库

Multiple processes cannot access one database file at the same time. 多个进程不能同时访问一个数据库文件。 A database file is locked by reader-writer lock while a process is connected to it. 与进程连接时,数据库文件被读写器锁锁定。 Note that the `BasicDB::ONOLOCK' option should not be used in order to escape the file locking mechanism. 请注意,不应使用`BasicDB :: ONOLOCK'选项以逃避文件锁定机制。 This option is for workaround against some file systems such as NFS, which does not support file locking mechanisms. 此选项是针对不支持文件锁定机制的某些文件系统(例如NFS)的解决方法。

If you want to get multiple processes to share one database, use Kyoto Tycoon instead. 如果要让多个进程共享一个数据库,请改用Kyoto Tycoon。 It is a lightweight database server as network interface to Kyoto Cabinet. 它是一种轻量级的数据库服务器,可作为到京都内阁的网络接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM