-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsqlite_options.dart
59 lines (48 loc) · 1.78 KB
/
sqlite_options.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class SqliteOptions {
/// SQLite journal mode. Defaults to [SqliteJournalMode.wal].
final SqliteJournalMode? journalMode;
/// SQLite synchronous flag. Defaults to [SqliteSynchronous.normal], which
/// is safe for WAL mode.
final SqliteSynchronous? synchronous;
/// Journal/WAL size limit. Defaults to 6MB.
/// The WAL may grow large than this limit during writes, but SQLite will
/// attempt to truncate the file afterwards.
final int? journalSizeLimit;
/// Timeout waiting for locks to be released by other connections.
/// Defaults to 30 seconds.
/// Set to null or [Duration.zero] to fail immediately when the database is locked.
final Duration? lockTimeout;
const SqliteOptions.defaults()
: journalMode = SqliteJournalMode.wal,
journalSizeLimit = 6 * 1024 * 1024, // 1.5x the default checkpoint size
synchronous = SqliteSynchronous.normal,
lockTimeout = const Duration(seconds: 30);
const SqliteOptions(
{this.journalMode = SqliteJournalMode.wal,
this.journalSizeLimit = 6 * 1024 * 1024,
this.synchronous = SqliteSynchronous.normal,
this.lockTimeout = const Duration(seconds: 30)});
}
/// SQLite journal mode. Set on the primary connection.
/// This library is written with WAL mode in mind - other modes may cause
/// unexpected locking behavior.
enum SqliteJournalMode {
/// Use a write-ahead log instead of a rollback journal.
/// This provides good performance and concurrency.
wal('WAL'),
delete('DELETE'),
truncate('TRUNCATE'),
persist('PERSIST'),
memory('MEMORY'),
off('OFF');
final String name;
const SqliteJournalMode(this.name);
}
/// SQLite file commit mode.
enum SqliteSynchronous {
normal('NORMAL'),
full('FULL'),
off('OFF');
final String name;
const SqliteSynchronous(this.name);
}