refactor: cache
This commit is contained in:
parent
6564d7fee0
commit
183b9ab119
|
@ -1,11 +1,18 @@
|
||||||
import {Hooks} from '@flecks/core';
|
import {Hooks} from '@flecks/core';
|
||||||
|
|
||||||
|
import {cache as resourceCache} from './resource';
|
||||||
|
|
||||||
export {default as Resource} from './resource';
|
export {default as Resource} from './resource';
|
||||||
export * as JSONB from './jsonb';
|
export * as JSONB from './jsonb';
|
||||||
export {default as JsonResource} from './json-resource';
|
export {default as JsonResource} from './json-resource';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
[Hooks]: {
|
[Hooks]: {
|
||||||
|
'@flecks/core.hmr': (path) => {
|
||||||
|
if ('@avocado/resource' === path) {
|
||||||
|
resourceCache.reset();
|
||||||
|
}
|
||||||
|
},
|
||||||
'@flecks/core.starting': (flecks) => {
|
'@flecks/core.starting': (flecks) => {
|
||||||
flecks.set('$avocado/resource.resources', flecks.gather(
|
flecks.set('$avocado/resource.resources', flecks.gather(
|
||||||
'@avocado/resource.resources',
|
'@avocado/resource.resources',
|
||||||
|
|
|
@ -8,16 +8,11 @@ const {
|
||||||
FLECKS_CORE_ROOT = process.cwd(),
|
FLECKS_CORE_ROOT = process.cwd(),
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
const cache = 'production' === process.env.NODE_ENV
|
export const cache = new LRU({
|
||||||
? new LRU({
|
length: (buffer) => buffer.length,
|
||||||
length: (buffer) => buffer.length,
|
max: 16 * 1024 * 1024,
|
||||||
max: 16 * 1024 * 1024,
|
maxAge: Infinity,
|
||||||
maxAge: Infinity,
|
});
|
||||||
})
|
|
||||||
: {
|
|
||||||
has: () => {},
|
|
||||||
set: () => {},
|
|
||||||
};
|
|
||||||
|
|
||||||
const decorate = compose(
|
const decorate = compose(
|
||||||
Property('uri'),
|
Property('uri'),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user