mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-21 15:56:10 +01:00
🎨 调整数据库缓存
This commit is contained in:
parent
6a5617dcc1
commit
19f44148d4
13 changed files with 17 additions and 22 deletions
|
|
@ -29,17 +29,17 @@ import (
|
|||
)
|
||||
|
||||
var memCache, _ = ristretto.NewCache(&ristretto.Config{
|
||||
NumCounters: 800000,
|
||||
MaxCost: 1000 * 1000 * 100,
|
||||
NumCounters: 10240,
|
||||
MaxCost: 1024,
|
||||
BufferItems: 64,
|
||||
})
|
||||
var disabled = true
|
||||
|
||||
func EnableCache() {
|
||||
func enableCache() {
|
||||
disabled = false
|
||||
}
|
||||
|
||||
func DisableCache() {
|
||||
func disableCache() {
|
||||
disabled = true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ func InitDatabase(forceRebuild bool) (err error) {
|
|||
defer initDatabaseLock.Unlock()
|
||||
|
||||
ClearBlockCache()
|
||||
DisableCache()
|
||||
defer EnableCache()
|
||||
disableCache()
|
||||
defer enableCache()
|
||||
|
||||
util.IncBootProgress(2, "Initializing database...")
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ func FlushQueue() {
|
|||
|
||||
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
||||
total := len(ops)
|
||||
if 512 < total {
|
||||
disableCache()
|
||||
defer enableCache()
|
||||
}
|
||||
|
||||
for i, op := range ops {
|
||||
if util.IsExiting {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue