在服务器应用程序中使用Sqlite?备择方案? [英] Using Sqlite in a server application? Alternatives?

查看:46
本文介绍了在服务器应用程序中使用Sqlite?备择方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下情形:数据库将在本地网络上使用,少数客户端一次连接到该数据库.有一张桌子.当一个客户端修改该表中的数据时,应通知其他连接的客户端.也许每个连接在服务器应用程序中只有一个线程.

Consider the following scenario: A database is to be used on a local network, to which a handful of clients connect at one time. There is one table. When one of the clients modifies the data in that table, the other connected clients should be notified. Perhaps there could be one thread in the server application per connection.

一个限制是,该限制不应要求用户安装和配置任何其他第三方数据库软件.这就是为什么要使用Sqlite的原因,因为应用程序本身可以与.db文件进行交互,而该文件可以捆绑在一起.

One constraint is that should not require the user to install and configure any other third-party database software. This is why Sqlite came to mind, since the application itself could just interact with the .db file, which can be bundled with it.

这是Sqlite可以实现的,还是这个想法完全错误并且被误导了?

Is this something that is achievable with Sqlite, or is this idea totally wrong and misguided?

说明此描述的简单图.

Simple diagram illustrating this description.

推荐答案

交流意见摘要:

答案是肯定的,您可以在此体系结构中使用SQLite.

the answer is yes, you can use SQLite for this architecture.

您可能还希望启用 WAL (预写日志记录),以增加并发:

You may also want to enable WAL (Write-Ahead Logging), in your case for increased concurrency:

...使用WAL代替回滚日志有优点和缺点.优点包括:

... There are advantages and disadvantages to using WAL instead of a rollback journal. Advantages include:

  1. 在大多数情况下,WAL明显更快.
  2. WAL提供更多的并发性,因为读者不会阻止作者,而作家也不会阻止读者.读写可以同时进行.
  3. 使用WAL时,磁盘I/O操作往往更加顺序化.
  4. WAL使用的fsync()操作要少得多,因此,在fsync()系统调用中断的系统上,该漏洞不太容易受到影响.

但是也有缺点:...

But there are also disadvantages: ...

对于问题的通知部分,我建议调查触发器:

For the notification part of the question, I suggest to investigate triggers:

...触发器是在发生指定的数据库事件时自动执行的数据库操作.

... Triggers are database operations that are automatically performed when a specified database event occurs.

每个触发器必须指定将为以下操作之一触发:DELETE,INSERT,UPDATE....

Each trigger must specify that it will fire for one of the following operations: DELETE, INSERT, UPDATE. ...

这篇关于在服务器应用程序中使用Sqlite?备择方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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