tabby/app/lib/lru.ts
Eugene Pankov 2470f5f941 LRU fix
2020-02-05 15:22:28 +03:00

18 lines
450 B
TypeScript

import * as createLRU from 'lru-cache'
import * as fs from 'fs'
const lru = createLRU({ max: 256, maxAge: 250 })
const origLstat = fs.realpathSync.bind(fs)
// NB: The biggest offender of thrashing realpathSync is the node module system
// itself, which we can't get into via any sane means.
require('fs').realpathSync = function (p) {
let r = lru.get(p)
if (r) {
return r
}
r = origLstat(p)
lru.set(p, r)
return r
}