@tramvai/module-common 2.125.4 → 2.130.4
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.
|
@@ -2,7 +2,7 @@ import { __decorate } from 'tslib';
|
|
|
2
2
|
import { createToken } from '@tinkoff/dippy';
|
|
3
3
|
import { Module, Scope, IS_DI_CHILD_CONTAINER_TOKEN } from '@tramvai/core';
|
|
4
4
|
import { CREATE_CACHE_TOKEN, CLEAR_CACHE_TOKEN, REGISTER_CLEAR_CACHE_TOKEN } from '@tramvai/tokens-common';
|
|
5
|
-
import { cacheFactory } from './cacheFactory.browser.js';
|
|
5
|
+
import { cacheFactory } from './cacheFactory.browser.browser.js';
|
|
6
6
|
import { providers } from './clientProviders.browser.js';
|
|
7
7
|
|
|
8
8
|
const cachesToken = createToken('_cachesList');
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import LRU from '@tinkoff/lru-cache-nano';
|
|
2
|
+
import LFU from '@akashbabu/lfu-cache';
|
|
2
3
|
|
|
4
|
+
class LFUToCacheAdapter extends LFU {
|
|
5
|
+
has(key) {
|
|
6
|
+
return typeof this.get(key) !== 'undefined';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
3
9
|
const cacheFactory = (type, options = { max: 100 }) => {
|
|
10
|
+
if (type === 'memory-lfu') {
|
|
11
|
+
if (typeof options === 'object' && 'ttl' in options) {
|
|
12
|
+
// ttl option is not supported by @akashbabu/lfu-cache
|
|
13
|
+
// eslint-disable-next-line no-param-reassign
|
|
14
|
+
options.maxAge = options.ttl;
|
|
15
|
+
}
|
|
16
|
+
return new LFUToCacheAdapter(options);
|
|
17
|
+
}
|
|
4
18
|
return new LRU(options);
|
|
5
19
|
};
|
|
6
20
|
|
|
@@ -3,12 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var LRU = require('@tinkoff/lru-cache-nano');
|
|
6
|
+
var LFU = require('@akashbabu/lfu-cache');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
9
|
|
|
9
10
|
var LRU__default = /*#__PURE__*/_interopDefaultLegacy(LRU);
|
|
11
|
+
var LFU__default = /*#__PURE__*/_interopDefaultLegacy(LFU);
|
|
10
12
|
|
|
13
|
+
class LFUToCacheAdapter extends LFU__default["default"] {
|
|
14
|
+
has(key) {
|
|
15
|
+
return typeof this.get(key) !== 'undefined';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
const cacheFactory = (type, options = { max: 100 }) => {
|
|
19
|
+
if (type === 'memory-lfu') {
|
|
20
|
+
if (typeof options === 'object' && 'ttl' in options) {
|
|
21
|
+
// ttl option is not supported by @akashbabu/lfu-cache
|
|
22
|
+
// eslint-disable-next-line no-param-reassign
|
|
23
|
+
options.maxAge = options.ttl;
|
|
24
|
+
}
|
|
25
|
+
return new LFUToCacheAdapter(options);
|
|
26
|
+
}
|
|
12
27
|
return new LRU__default["default"](options);
|
|
13
28
|
};
|
|
14
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.130.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"browser": {
|
|
12
12
|
"./lib/actions/actionPageRunner.js": "./lib/actions/actionPageRunner.browser.js",
|
|
13
13
|
"./lib/cache/serverProviders.js": "./lib/cache/clientProviders.js",
|
|
14
|
+
"./lib/cache/cacheFactory.js": "./lib/cache/cacheFactory.browser.js",
|
|
14
15
|
"./lib/index.es.js": "./lib/index.browser.js",
|
|
15
16
|
"./lib/providers/serverProviders.js": "./lib/providers/clientProviders.js",
|
|
16
17
|
"./lib/child-app/serverProviders.js": "./lib/child-app/clientProviders.js",
|
|
@@ -30,30 +31,31 @@
|
|
|
30
31
|
"@tinkoff/errors": "0.3.8",
|
|
31
32
|
"@tinkoff/hook-runner": "0.4.6",
|
|
32
33
|
"@tinkoff/lru-cache-nano": "^7.8.1",
|
|
34
|
+
"@akashbabu/lfu-cache": "1.0.2",
|
|
33
35
|
"@tinkoff/pubsub": "0.5.7",
|
|
34
36
|
"@tinkoff/url": "0.8.6",
|
|
35
|
-
"@tramvai/experiments": "2.
|
|
36
|
-
"@tramvai/module-cookie": "2.
|
|
37
|
-
"@tramvai/module-environment": "2.
|
|
38
|
-
"@tramvai/module-log": "2.
|
|
39
|
-
"@tramvai/tokens-child-app": "2.
|
|
40
|
-
"@tramvai/tokens-core-private": "2.
|
|
41
|
-
"@tramvai/tokens-common": "2.
|
|
42
|
-
"@tramvai/tokens-render": "2.
|
|
43
|
-
"@tramvai/tokens-server-private": "2.
|
|
44
|
-
"@tramvai/types-actions-state-context": "2.
|
|
37
|
+
"@tramvai/experiments": "2.130.4",
|
|
38
|
+
"@tramvai/module-cookie": "2.130.4",
|
|
39
|
+
"@tramvai/module-environment": "2.130.4",
|
|
40
|
+
"@tramvai/module-log": "2.130.4",
|
|
41
|
+
"@tramvai/tokens-child-app": "2.130.4",
|
|
42
|
+
"@tramvai/tokens-core-private": "2.130.4",
|
|
43
|
+
"@tramvai/tokens-common": "2.130.4",
|
|
44
|
+
"@tramvai/tokens-render": "2.130.4",
|
|
45
|
+
"@tramvai/tokens-server-private": "2.130.4",
|
|
46
|
+
"@tramvai/types-actions-state-context": "2.130.4",
|
|
45
47
|
"hoist-non-react-statics": "^3.3.1",
|
|
46
48
|
"node-abort-controller": "^3.0.1"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
51
|
"@tinkoff/dippy": "0.8.15",
|
|
50
52
|
"@tinkoff/utils": "^2.1.2",
|
|
51
|
-
"@tramvai/cli": "2.
|
|
52
|
-
"@tramvai/core": "2.
|
|
53
|
-
"@tramvai/papi": "2.
|
|
54
|
-
"@tramvai/react": "2.
|
|
55
|
-
"@tramvai/state": "2.
|
|
56
|
-
"@tramvai/tokens-server": "2.
|
|
53
|
+
"@tramvai/cli": "2.130.4",
|
|
54
|
+
"@tramvai/core": "2.130.4",
|
|
55
|
+
"@tramvai/papi": "2.130.4",
|
|
56
|
+
"@tramvai/react": "2.130.4",
|
|
57
|
+
"@tramvai/state": "2.130.4",
|
|
58
|
+
"@tramvai/tokens-server": "2.130.4",
|
|
57
59
|
"react": ">=16.14.0",
|
|
58
60
|
"tslib": "^2.4.0"
|
|
59
61
|
},
|
|
File without changes
|