Page 1 of 1

Using TLiteConnection from threads

Posted: Fri 09 Sep 2016 01:13
by Max Terentiev
Hi,

Can I use one TLiteConnection from multiple threads in same time without any synchronization in my code (TCriticalSection, Synchronize, etc) ? Or I must create separate TLiteConnection in each thread ? Can't find anything about it in Help file.

And second question: should I use TLiteConnection.Options.EnableSharedCache for best perfromance if I read/write to database from threads ?

Thanks for help !

Re: Using TLiteConnection from threads

Posted: Fri 09 Sep 2016 13:31
by AlexP
Hello,

Yes, LiteDAC allows working with SQLite in threads: for parallel access to a DB from different threads, extended options were added to delimit simultaneous access to a DB: BusyTimeout, EnableSharedCache, ReadUncommitted. You can find more detailed information on these options in the LiteDAC help.

P.S. Moreover, SQLite thread-safety depends on the value of the SQLITE_THREADSAFE option, that was set when building the SQLite library. In the Direct mode, we use the value "1" supposing full thread-safety.You can refer to the SQLite developers site for more detailed information: http://www.sqlite.org/compile.html#threadsafe ,
http://www.sqlite.org/threadsafe.html .