-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
61 lines (57 loc) · 1.99 KB
/
index.php
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
60
61
<?php
@include_once __DIR__ . '/vendor/autoload.php';
if (!class_exists('Bnomei\SQLiteCache')) {
require_once __DIR__ . '/classes/SQLiteCache.php';
}
if (! function_exists('feather')) {
function feather(array $options = [])
{
return \Bnomei\SQLiteCache::singleton($options);
}
}
Kirby::plugin('bnomei/sqlite-cachedriver', [
'options' => [
'cache' => true, // create cache folder
// https://sqlite.org/pragma.html
'pragmas-construct' => function () {
$defaults = [
'PRAGMA read_uncommitted = true;',
'PRAGMA busy_timeout = 5000;',
'PRAGMA main.cache_size = 10000;',
'PRAGMA case_sensitive_like = false',
'PRAGMA main.auto_vacuum = INCREMENTAL;',
'PRAGMA main.page_size = 4096;',
'PRAGMA temp_store = MEMORY;',
];
if (SQLite3::version() >= 3007001) {
return array_merge($defaults, [
//'PRAGMA main.locking_mode = EXCLUSIVE;',
'PRAGMA main.synchronous = NORMAL;',
'PRAGMA main.journal_mode = WAL;',
]);
} else {
return array_merge($defaults, [
'PRAGMA main.synchronous = OFF;',
'PRAGMA main.journal_mode = MEMORY;',
]);
}
},
'pragmas-destruct' => function () {
$defaults = [
'PRAGMA main.incremental_vacuum;',
];
if (SQLite3::version() >= 3007001) {
return array_merge($defaults, [
'PRAGMA main.wal_checkpoint(TRUNCATE);',
'PRAGMA main.synchronous = NORMAL;',
//'PRAGMA main.locking_mode = NORMAL;',
]);
} else {
return array_merge($defaults, []);
}
},
],
'cacheTypes' => [
'sqlite' => \Bnomei\SQLiteCache::class
],
]);