Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Should I use FullMutex or NoMutex in SQLite Flags? 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");
    }
}
like image 460
Echo Lumaque Avatar asked Feb 14 '26 04:02

Echo Lumaque


1 Answers

  1. What NoMutex mean is that the new database connection will use the "multi-thread" threading mode. 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.

  2. What FullMutext mean is that new database connection will use the "serialized" threading mode. 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

like image 86
Adrain Avatar answered Feb 16 '26 18:02

Adrain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!