miolo 3.0.0-beta.197 → 3.0.0-beta.199

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,7 +44,8 @@ export async function miolo_build_options_for_server(
44
44
  externals({
45
45
  packagePath: path.join(pkgPath, "package.json"),
46
46
  deps: !bundleDeps,
47
- peerDeps: !bundleDeps
47
+ peerDeps: !bundleDeps,
48
+ include: ["@node-rs/xxhash"]
48
49
  }),
49
50
  nodeResolve({
50
51
  rootDir: pkgPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miolo",
3
- "version": "3.0.0-beta.197",
3
+ "version": "3.0.0-beta.199",
4
4
  "description": "all-in-one koa-based server",
5
5
  "author": "Donato Lorenzo <donato@afialapis.com>",
6
6
  "contributors": [
@@ -1,15 +1,21 @@
1
1
  import { cacheiro } from "cacheiro"
2
- import { miolo_cacher_options_for_custom, miolo_cacher_options_for_default } from "./options.mjs"
2
+ import { miolo_cacher_options_for_custom, miolo_cacher_options_for_fly } from "./options.mjs"
3
3
 
4
4
  let _glob_cache_mother
5
+ const _local_cache_instances = new Map()
5
6
 
6
7
  const _get_cache_mother = async (config, logger) => {
7
8
  if (_glob_cache_mother === undefined) {
8
- const default_options = miolo_cacher_options_for_default(config, logger)
9
- _glob_cache_mother = await cacheiro({
10
- ...default_options,
11
- namespace: "miolo-cache-stores"
12
- })
9
+ const default_options = miolo_cacher_options_for_fly(
10
+ config,
11
+ {
12
+ type: process.env.MIOLO_CACHE_TYPE || "combined",
13
+ namespace: "miolo-cache-mother"
14
+ },
15
+ logger
16
+ )
17
+
18
+ _glob_cache_mother = await cacheiro(default_options)
13
19
  }
14
20
  return _glob_cache_mother
15
21
  }
@@ -21,7 +27,8 @@ export function init_context_cache(config, logger) {
21
27
  const cache_mother = await _get_cache_mother(config, logger)
22
28
 
23
29
  const cache_instance = await cacheiro(custom_options?.[name] || {})
24
- await cache_mother.setItem(name, cache_instance)
30
+ await cache_mother.setItem(name, "1")
31
+ _local_cache_instances.set(name, cache_instance)
25
32
  return cache_instance
26
33
  }
27
34
 
@@ -30,13 +37,20 @@ export function init_context_cache(config, logger) {
30
37
  }
31
38
 
32
39
  const get_cache = async (name) => {
40
+ if (_local_cache_instances.has(name)) {
41
+ return _local_cache_instances.get(name)
42
+ }
43
+
33
44
  const cache_mother = await _get_cache_mother(config, logger)
34
45
 
35
- let cache_instance = await cache_mother.getItem(name)
36
- if (cache_instance === undefined) {
37
- cache_instance = await _init_cache_instance(name)
46
+ const exists_in_mother = await cache_mother.getItem(name)
47
+ if (exists_in_mother) {
48
+ const cache_instance = await cacheiro(custom_options?.[name] || {})
49
+ _local_cache_instances.set(name, cache_instance)
50
+ return cache_instance
38
51
  }
39
- return cache_instance
52
+
53
+ return await _init_cache_instance(name)
40
54
  }
41
55
 
42
56
  const get_cache_names = async (pattern = "*") => {
@@ -56,6 +70,7 @@ export function init_context_cache(config, logger) {
56
70
  }
57
71
  }
58
72
  }
73
+ _local_cache_instances.delete(name)
59
74
 
60
75
  const cache_mother = await _get_cache_mother(config, logger)
61
76
  await cache_mother.unsetItem(name)
@@ -65,16 +80,16 @@ export function init_context_cache(config, logger) {
65
80
  const cache_mother = await _get_cache_mother(config, logger)
66
81
 
67
82
  if (clean) {
68
- const cache_names = await cache_mother.getKeys("*")
69
- for (const name of cache_names) {
83
+ for (const cache of _local_cache_instances.values()) {
70
84
  try {
71
- const cache = await cache_mother.getItem(name)
72
85
  await cache.close()
73
86
  } catch (error) {
74
87
  logger.warn(error)
75
88
  }
76
89
  }
77
90
  }
91
+ _local_cache_instances.clear()
92
+
78
93
  await cache_mother.close()
79
94
  _glob_cache_mother = undefined
80
95
  }
@@ -27,10 +27,10 @@ function _miolo_cacher_options_merge(def, opt, logger) {
27
27
  }
28
28
  }
29
29
 
30
- export function miolo_cacher_options_for_default(config, logger) {
30
+ export function miolo_cacher_options_for_fly(config, options, logger) {
31
31
  const d = config.cache.default
32
32
 
33
- return _miolo_cacher_options_merge(d, {}, logger)
33
+ return _miolo_cacher_options_merge(d, options, logger)
34
34
  }
35
35
 
36
36
  export function miolo_cacher_options_for_calustra(config, logger) {
@@ -45,9 +45,9 @@
45
45
  "intre": "^3.0.0-beta.4",
46
46
  "joi": "^18.2.1",
47
47
  "lucide-react": "^1.16.0",
48
- "miolo-cli": "^3.0.0-beta.197",
48
+ "miolo-cli": "^3.0.0-beta.199",
49
49
  "miolo-model": "file:../miolo-model",
50
- "miolo-react": "^3.0.0-beta.197",
50
+ "miolo-react": "^3.0.0-beta.199",
51
51
  "next-themes": "^0.4.6",
52
52
  "radix-ui": "^1.4.3",
53
53
  "react": "^19.2.6",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@biomejs/biome": "2.4.15",
65
- "miolo": "^3.0.0-beta.197",
65
+ "miolo": "^3.0.0-beta.199",
66
66
  "sass-embedded": "^1.99.0"
67
67
  },
68
68
  "overrides": {
@@ -70,6 +70,7 @@
70
70
  "ajv": "6.14.0",
71
71
  "body-parser": "^2.2.2",
72
72
  "cookie": "^1.1.1",
73
+ "depd": "2.0.0",
73
74
  "express": "^5.2.1",
74
75
  "jsonwebtoken": "^9.0.3",
75
76
  "lodash": "^4.17.23",