应用程序之间共享数据 - 共享内存、D-Bus 和文件操作

发布于 2024-12-22 14:20:42 字数 280 浏览 1 评论 0原文

考虑两个应用程序必须在它们之间共享数据的场景。我可以想到三种方法

  1. - 共享内存(允许我使用 Boost)
  2. D-Bus(允许 glib / Qt 实现)
  3. 两个应用程序之间对公共文件的文件操作。

Q1.考虑到要共享的数据将非常大(例如,一些 10K 歌曲名称),这应该是我的方法。

Q2。与其他操作相比,进行文件操作是否会影响速度,因为会涉及硬盘?

Q3。还有其他速度更快的方法吗?

实现语言-C++

Consider a scenario in which two applications have to share data among them. I can think of three ways-

  1. Shared memory ( Boost I am allowed to use )
  2. D-Bus ( glib / Qt implementation allowed )
  3. File operations on a common file between the two application.

Q1. Which should be my approach considering data to be shared is going to be very large ( some 10K song names for example ).

Q2. Will doing file operation affect speed, compared to the others, as Hard disk would be involved ?

Q3. Is there any other approach available with better speed?

Language of implementation - C++

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青萝楚歌 2024-12-29 14:20:42

您可能需要考虑使用 QtSql 模块来使用数据库,特别是 SQLite。

SQLite 数据库是一个跨平台的进程内数据库引擎。这使您可以轻松存储结构化数据并在进程之间并发且安全地访问它,进程甚至可以用不同的语言编写。

SQLite 可以很好地处理数百万条记录,非常快速且可靠。
主要问题是进程都在写入,因为它使用数据库级锁定,因此在写入操作期间没有其他进程可以读取或写入数据库。

使用 QtSql 的另一个好处是,将来您可以使用 PostgreSQL 或 MySQL 等数据库服务器轻松地使程序在网络上运行。

You may want to consider using the QtSql module to use a database, specifically SQLite.

The SQLite database is a cross-platform in-process database engine. This allows you to store structured data easily and access it concurrently and safely between processes, the processes can even be written in different languages.

SQLite works fine with millions of records, is very fast and reliable.
The main problem is with processes both writing as it uses database level locking, so no other process can read or write to the database during the write operation.

The other benefit to using QtSql is that in the future you can easily make the programs work across a network by using a database server such as PostgreSQL or MySQL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文