简体   繁体   English

我应该在 Xamarin.Forms 上使用哪些 SQLite (sqlite-net-pcl) 标志?

[英]Which SQLite (sqlite-net-pcl) flags should I use on Xamarin.Forms?

Should I use FullMutex or NoMutex in SQLite Flags?我应该在 SQLite Flags 中使用 FullMutex 还是 NoMutex? What is their purpose?他们的目的是什么? And if yes, which should I use?如果是,我应该使用哪个?

For now: I'm using these flags:现在:我正在使用这些标志:

public static class SQLiteConstants
{
    public const SQLiteOpenFlags Flags =
        SQLiteOpenFlags.ReadWrite |
        SQLiteOpenFlags.SharedCache |
        SQLiteOpenFlags.Create |
        SQLiteOpenFlags.FullMutex;

    public static string GetDatabasePath
    {
        get => Path.Combine(FileSystem.AppDataDirectory, "UserScores.db3");
    }
}
  1. What NoMutex mean is that the new database connection will use the "multi-thread" threading mode. NoMutex 的意思是新的数据库连接将使用“多线程”线程模式。 This means that separate threads are allowed to use SQLite at the same time, as long as each thread is using a different database connection.这意味着允许单独的线程同时使用 SQLite,只要每个线程使用不同的数据库连接。

  2. What FullMutext mean is that new database connection will use the "serialized" threading mode. FullMutext 的意思是新的数据库连接将使用“序列化”线程模式。 This means the multiple threads can safely attempt to use the same database connection at the same time.这意味着多个线程可以安全地同时尝试使用同一个数据库连接。 (Mutexes will block any actual concurrency, but in this mode there is no harm in trying.) So, you can choose the flag depend on your situation (互斥量会阻塞任何实际的并发,但在这种模式下尝试没有坏处。)因此,您可以根据自己的情况选择标志

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

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