Cache: Rewrite based on lua-lru

Ought to be faster than our naive array-based approach.
Especially for the glyph cache, which has a solid amount of elements,
and is mostly cache hits.
(There are few things worse for performance in Lua than
table.remove @ !tail and table.insert @ !tail, which this was full of :/).

DocCache: New module that's now an actual Cache instance instead of a
weird hack. Replaces "Cache" (the instance) as used across Document &
co.
Only Cache instance with on-disk persistence.

ImageCache: Update to new Cache.

GlyphCache: Update to new Cache.
Also, actually free glyph bbs on eviction.
This commit is contained in:
NiLuJe
2021-05-04 23:13:24 +02:00
parent ce624be8b8
commit 21b067792d
15 changed files with 243 additions and 229 deletions

View File

@@ -1,10 +1,10 @@
describe("Koptinterface module", function()
local DocumentRegistry, Koptinterface, Cache
local DocCache, DocumentRegistry, Koptinterface
setup(function()
require("commonrequire")
DocCache = require("document/doccache")
DocumentRegistry = require("document/documentregistry")
Koptinterface = require("document/koptinterface")
Cache = require("cache")
end)
local tall_pdf = "spec/front/unit/data/tall.pdf"
@@ -19,7 +19,7 @@ describe("Koptinterface module", function()
doc.configurable.text_wrap = 0
complex_doc.configurable.text_wrap = 0
paper_doc.configurable.text_wrap = 0
Cache:clear()
DocCache:clear()
end)
after_each(function()