perf: cache
This commit is contained in:
parent
7646f8507e
commit
c012ee7faf
|
@ -1,12 +1,18 @@
|
|||
import {Flecks, Hooks} from '@flecks/core';
|
||||
|
||||
import globals from './globals';
|
||||
import {cache} from './resources/script';
|
||||
|
||||
export default {
|
||||
[Hooks]: {
|
||||
'@avocado/behavior.globals': globals,
|
||||
'@avocado/resource.resources': Flecks.provide(require.context('./resources', false, /\.js$/)),
|
||||
'@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)),
|
||||
'@flecks/core.hmr': (path) => {
|
||||
if ('@avocado/behavior' === path) {
|
||||
cache.reset();
|
||||
}
|
||||
},
|
||||
'@flecks/core.starting': async (flecks) => {
|
||||
flecks.set('$avocado/behavior.globals', flecks.invokeMerge('@avocado/behavior.globals'));
|
||||
},
|
||||
|
|
|
@ -7,15 +7,10 @@ import LRU from 'lru-cache';
|
|||
|
||||
const Populated = Symbol.for('@avocado/behavior.populated');
|
||||
|
||||
const cache = 'production' === process.env.NODE_ENV
|
||||
? new LRU({
|
||||
max: 128,
|
||||
maxAge: Infinity,
|
||||
})
|
||||
: {
|
||||
has: () => {},
|
||||
set: () => {},
|
||||
};
|
||||
export const cache = new LRU({
|
||||
max: 128,
|
||||
maxAge: Infinity,
|
||||
});
|
||||
|
||||
const empty = {
|
||||
type: 'File',
|
||||
|
|
Loading…
Reference in New Issue
Block a user