How do I notify a process of an SQLite database change done in a different process?

前端 未结 7 2499
南笙
南笙 2021-02-19 16:27

Let\'s say I have two or more processes dealing with an SQLite database - a \"player\" process and many \"editor\" processes.

The \"player\" process reads the database

7条回答
  •  无人及你
    2021-02-19 17:19

    I think in that case, I would make a process to manage the database read/writes.

    Each editor that want to make some modifications to the database makes a call to this proccess, be it through IPC or network, or whatever method.

    This process can then notify the player of a change in the database. The player, when he wants to retrieve some data should make a request of the data it wants to the process managing the database. (Or the db process tells it what it needs, when it notifies of a change, so no request from the player needed)

    Doing this will have the advantage of having only one process accessing the SQLite DB, so no locking or concurrency issues on the database.

提交回复
热议问题