enhance: replace atom blocks-ast-cache by lrucache

This commit is contained in:
rcmerci
2025-04-03 22:14:27 +08:00
parent 1c24fff543
commit d05a8ac07f
5 changed files with 45 additions and 38 deletions

View File

@@ -347,25 +347,6 @@
:db/async-queries (atom {})
:db/latest-transacted-entity-uuids (atom {})})))
;; Block ast state
;; ===============
;; block uuid -> {content(String) -> ast}
(def blocks-ast-cache (atom {}))
(defn add-block-ast-cache!
[block-uuid content ast]
(when (and block-uuid content ast)
(let [new-value (assoc-in @blocks-ast-cache [block-uuid content] ast)
new-value (if (> (count new-value) 10000)
(into {} (take 5000 new-value))
new-value)]
(reset! blocks-ast-cache new-value))))
(defn get-block-ast
[block-uuid content]
(when (and block-uuid content)
(get-in @blocks-ast-cache [block-uuid content])))
;; User configuration getters under :config (and sometimes :me)
;; ========================================
;; TODO: Refactor default config values to be data driven. Currently they are all