add caching for load_var
This commit is contained in:
parent
c1a2833dd8
commit
859e49e7ce
12
server.js
12
server.js
@ -875,7 +875,17 @@ import LRU from "lru-cache"
|
||||
|
||||
ejs.cache = new LRU({max:20})
|
||||
|
||||
const load_var_cache = new LRU({
|
||||
max: 20,
|
||||
maxSize: 10000,
|
||||
ttl: 1000 * 60,
|
||||
allowStale: true,
|
||||
updateAgeOnGet: true,
|
||||
updateAgeOnHas: true
|
||||
})
|
||||
|
||||
function load_var(fina) {
|
||||
if(load_var_cache.get(fina))return load_var_cache.get(fina)
|
||||
if(!existsSync(fina)) {
|
||||
console.log(1,"tried loading non-existent file",fina)
|
||||
return "";
|
||||
@ -893,6 +903,8 @@ function load_var(fina) {
|
||||
return styles
|
||||
}
|
||||
|
||||
load_var_cache.set(fina,out)
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user