iPhone 版 Sqlite 的替代品 [monotouch]

发布于 2024-09-09 06:47:52 字数 136 浏览 1 评论 0原文

正如标题所说。

我发现我遇到的很多问题都与在 Monotouch 中使用 Sqlite 所需的 Sqlite 包装器中缺乏线程安全有关 - 所以 - 问题是 - 有替代方案吗?一定有某些东西!!?

w://

Like the title says.

I find a lot of the issues I have are related to the lack of thread safety in the Sqlite wrapper needed for using Sqlite with Monotouch - so - the question is - is there an alternative? There must be something!!?

w://

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

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

发布评论

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

评论(2

分开我的手 2024-09-16 06:47:52

Sqlite本身不是线程安全的,因此每次访问数据库时都需要手动加锁。您可以看到我如何使用 TweetStation 做到这一点:

http://github.com/migueldeicaza/TweetStation/

这允许我在后台更新数据库。

有几个到 Sqlite 的绑定:sqlite-net,它是一个小型的 Sqlite 绑定或 Mono.Data.Sqlite。

至于CoreData,它也会有同样的问题,你不能免费获得线程安全,你也需要遵循他们的规则。

Sqlite itself is not thread safe, so you need to manually take a lock whenever you are going to access the database. You can see how I did this with TweetStation:

http://github.com/migueldeicaza/TweetStation/

This allows me to update the database in the background.

There are a couple of bindings to Sqlite: sqlite-net which is a tiny Sqlite binding or Mono.Data.Sqlite.

As for CoreData, it would have the same problems, you do not get thread safety for free, you need to follow their rules as well.

水水月牙 2024-09-16 06:47:52

在 iOS 4 中,您可以调用 sqlite3_config( SQLITE_CONFIG_SERIALIZED ),或在 C# 中使用 Sqlite3 包装器:

    var result = SQLite3.Config(SQLite3.ConfigOption.Serialized);
    if (result != SQLite3.Result.OK)
    {
        throw new InvalidProgramException("sqlite3 refused Serialized option");
    }

In iOS 4, you can call sqlite3_config( SQLITE_CONFIG_SERIALIZED ), or using Sqlite3 wrapper in C#:

    var result = SQLite3.Config(SQLite3.ConfigOption.Serialized);
    if (result != SQLite3.Result.OK)
    {
        throw new InvalidProgramException("sqlite3 refused Serialized option");
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文