@atlaspack/cache 3.2.48 → 3.2.50
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.
- package/CHANGELOG.md +28 -0
- package/dist/FSCache.js +0 -9
- package/dist/LMDBLiteCache.js +10 -35
- package/lib/FSCache.js +0 -21
- package/lib/LMDBLiteCache.js +10 -41
- package/package.json +7 -7
- package/src/FSCache.ts +0 -9
- package/src/LMDBLiteCache.ts +13 -43
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @atlaspack/cache
|
|
2
2
|
|
|
3
|
+
## 3.2.50
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1035](https://github.com/atlassian-labs/atlaspack/pull/1035) [`936209f`](https://github.com/atlassian-labs/atlaspack/commit/936209f3c6c201288720dd62b61e1f538368268c) Thanks [@marcins](https://github.com/marcins)! - Remove `cachePerformanceImprovements` feature flag
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`06bb8c1`](https://github.com/atlassian-labs/atlaspack/commit/06bb8c14657722658c55283835f23ed7e7c6ecb4), [`a2d8e7a`](https://github.com/atlassian-labs/atlaspack/commit/a2d8e7a2444a1d6502239de8b8ceab4227270ec7), [`f9aec27`](https://github.com/atlassian-labs/atlaspack/commit/f9aec2736d27afa7a1f2a9701d46e29e566ab352), [`ecf8b79`](https://github.com/atlassian-labs/atlaspack/commit/ecf8b7931c5516df2117d525cefff5d7e1d20bee), [`93ec107`](https://github.com/atlassian-labs/atlaspack/commit/93ec10729ad5a328b4320955357339746cd472f3), [`a2c5747`](https://github.com/atlassian-labs/atlaspack/commit/a2c574770d2e616576e817801842576ead072532), [`f216e22`](https://github.com/atlassian-labs/atlaspack/commit/f216e227e0aca8a3944f66267d3f75238c732802), [`e88b258`](https://github.com/atlassian-labs/atlaspack/commit/e88b25808a181fafbe98e5ca278b35bfc0197caf), [`ad3c822`](https://github.com/atlassian-labs/atlaspack/commit/ad3c8223ab1abce9e8da81239cc56f27d37c7cad), [`936209f`](https://github.com/atlassian-labs/atlaspack/commit/936209f3c6c201288720dd62b61e1f538368268c), [`857962a`](https://github.com/atlassian-labs/atlaspack/commit/857962a352bb0aebaf74a8765e8c44d7e875a4e9)]:
|
|
10
|
+
- @atlaspack/rust@3.24.0
|
|
11
|
+
- @atlaspack/feature-flags@2.30.1
|
|
12
|
+
- @atlaspack/fs@2.15.50
|
|
13
|
+
- @atlaspack/logger@2.14.47
|
|
14
|
+
- @atlaspack/utils@3.3.7
|
|
15
|
+
- @atlaspack/build-cache@2.13.13
|
|
16
|
+
|
|
17
|
+
## 3.2.49
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#1017](https://github.com/atlassian-labs/atlaspack/pull/1017) [`3ad8e88`](https://github.com/atlassian-labs/atlaspack/commit/3ad8e880c4c2b9126cbfb6963a3862a75306a26f) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - reduce test lmdbcache mapsize and remove unused setup-cache
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`c4082ba`](https://github.com/atlassian-labs/atlaspack/commit/c4082ba3fc1a9328a2e5f23195d5972fbc5d10c8), [`d8e984b`](https://github.com/atlassian-labs/atlaspack/commit/d8e984b7f6d04fa03707fa299bfd8b8bf9f58280), [`ca78e1d`](https://github.com/atlassian-labs/atlaspack/commit/ca78e1d2007bfecd267b283d66a73f3695da4234), [`94e1a58`](https://github.com/atlassian-labs/atlaspack/commit/94e1a58a1a8ed5a4e329745d8a7e6a9530b5cb11), [`4c1f39a`](https://github.com/atlassian-labs/atlaspack/commit/4c1f39a911acaefd630d877af1ae5a039931662f), [`fcf7ec5`](https://github.com/atlassian-labs/atlaspack/commit/fcf7ec56fea644e21f7a67d649e6efd1f03c4a6e), [`45a0dc5`](https://github.com/atlassian-labs/atlaspack/commit/45a0dc530fd9472dbfdebcbb05f1aad812ab3b23)]:
|
|
24
|
+
- @atlaspack/rust@3.23.0
|
|
25
|
+
- @atlaspack/feature-flags@2.30.0
|
|
26
|
+
- @atlaspack/utils@3.3.6
|
|
27
|
+
- @atlaspack/fs@2.15.49
|
|
28
|
+
- @atlaspack/logger@2.14.46
|
|
29
|
+
- @atlaspack/build-cache@2.13.12
|
|
30
|
+
|
|
3
31
|
## 3.2.48
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/FSCache.js
CHANGED
|
@@ -13,8 +13,6 @@ exports.FSCache = void 0;
|
|
|
13
13
|
const stream_1 = __importDefault(require("stream"));
|
|
14
14
|
const path_1 = __importDefault(require("path"));
|
|
15
15
|
const util_1 = require("util");
|
|
16
|
-
const rust_1 = require("@atlaspack/rust");
|
|
17
|
-
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
18
16
|
const logger_1 = __importDefault(require("@atlaspack/logger"));
|
|
19
17
|
const build_cache_1 = require("@atlaspack/build-cache");
|
|
20
18
|
// flowlint-next-line untyped-import:off
|
|
@@ -41,10 +39,6 @@ class FSCache {
|
|
|
41
39
|
await Promise.all(dirPromises);
|
|
42
40
|
}
|
|
43
41
|
_getCachePath(cacheId) {
|
|
44
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
45
|
-
const cleanId = (0, rust_1.hashString)(cacheId);
|
|
46
|
-
return path_1.default.join(this.dir, cleanId.slice(0, 2), cleanId.slice(2));
|
|
47
|
-
}
|
|
48
42
|
return path_1.default.join(this.dir, cacheId.slice(0, 2), cacheId.slice(2));
|
|
49
43
|
}
|
|
50
44
|
getStream(key) {
|
|
@@ -155,9 +149,6 @@ class FSCache {
|
|
|
155
149
|
}
|
|
156
150
|
exports.FSCache = FSCache;
|
|
157
151
|
_FSCache_instances = new WeakSet(), _FSCache_getFilePath = function _FSCache_getFilePath(key, index) {
|
|
158
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
159
|
-
return path_1.default.join(this.dir, `${(0, rust_1.hashString)(key)}-${index}`);
|
|
160
|
-
}
|
|
161
152
|
return path_1.default.join(this.dir, `${key}-${index}`);
|
|
162
153
|
}, _FSCache_unlinkChunks = async function _FSCache_unlinkChunks(key, index) {
|
|
163
154
|
try {
|
package/dist/LMDBLiteCache.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.LMDBLiteCache = exports.LmdbWrapper = void 0;
|
|
7
7
|
exports.open = open;
|
|
8
8
|
const build_cache_1 = require("@atlaspack/build-cache");
|
|
9
|
-
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
10
9
|
const rust_1 = require("@atlaspack/rust");
|
|
11
10
|
// @ts-expect-error TS7016
|
|
12
11
|
const ncp_1 = __importDefault(require("ncp"));
|
|
@@ -57,7 +56,7 @@ openOptions) {
|
|
|
57
56
|
path: directory,
|
|
58
57
|
asyncWrites: true,
|
|
59
58
|
mapSize: process.env.ATLASPACK_BUILD_ENV === 'test'
|
|
60
|
-
?
|
|
59
|
+
? 256 * 1024 * 1024
|
|
61
60
|
: 1024 * 1024 * 1024 * 15,
|
|
62
61
|
}));
|
|
63
62
|
}
|
|
@@ -81,9 +80,7 @@ class LMDBLiteCache {
|
|
|
81
80
|
return this.store.lmdb;
|
|
82
81
|
}
|
|
83
82
|
async ensure() {
|
|
84
|
-
|
|
85
|
-
await this.fsCache.ensure();
|
|
86
|
-
}
|
|
83
|
+
await this.fsCache.ensure();
|
|
87
84
|
await this.fs.mkdirp(this.cacheFilesDirectory);
|
|
88
85
|
return Promise.resolve();
|
|
89
86
|
}
|
|
@@ -109,18 +106,10 @@ class LMDBLiteCache {
|
|
|
109
106
|
await this.setBlob(key, (0, build_cache_1.serialize)(value));
|
|
110
107
|
}
|
|
111
108
|
getStream(key) {
|
|
112
|
-
|
|
113
|
-
return this.fs.createReadStream(path_1.default.join(this.dir, key));
|
|
114
|
-
}
|
|
115
|
-
return this.fs.createReadStream(this.getFileKey(key));
|
|
109
|
+
return this.fs.createReadStream(path_1.default.join(this.dir, key));
|
|
116
110
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return pipeline(stream, this.fs.createWriteStream(path_1.default.join(this.dir, key)));
|
|
120
|
-
}
|
|
121
|
-
const filePath = this.getFileKey(key);
|
|
122
|
-
await this.fs.mkdirp(path_1.default.dirname(filePath));
|
|
123
|
-
return pipeline(stream, this.fs.createWriteStream(filePath));
|
|
111
|
+
setStream(key, stream) {
|
|
112
|
+
return pipeline(stream, this.fs.createWriteStream(path_1.default.join(this.dir, key)));
|
|
124
113
|
}
|
|
125
114
|
// eslint-disable-next-line require-await
|
|
126
115
|
async getBlob(key) {
|
|
@@ -140,33 +129,19 @@ class LMDBLiteCache {
|
|
|
140
129
|
return Promise.resolve(this.store.get(key));
|
|
141
130
|
}
|
|
142
131
|
hasLargeBlob(key) {
|
|
143
|
-
|
|
144
|
-
return this.fsCache.hasLargeBlob(key);
|
|
145
|
-
}
|
|
146
|
-
return this.fs.exists(this.getFileKey(key));
|
|
132
|
+
return this.fsCache.hasLargeBlob(key);
|
|
147
133
|
}
|
|
148
134
|
getLargeBlob(key) {
|
|
149
|
-
|
|
150
|
-
return this.fsCache.getLargeBlob(key);
|
|
151
|
-
}
|
|
152
|
-
return this.fs.readFile(this.getFileKey(key));
|
|
135
|
+
return this.fsCache.getLargeBlob(key);
|
|
153
136
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return this.fsCache.setLargeBlob(key, contents, options);
|
|
157
|
-
}
|
|
158
|
-
const targetPath = this.getFileKey(key);
|
|
159
|
-
await this.fs.mkdirp(path_1.default.dirname(targetPath));
|
|
160
|
-
return this.fs.writeFile(targetPath, contents);
|
|
137
|
+
setLargeBlob(key, contents, options) {
|
|
138
|
+
return this.fsCache.setLargeBlob(key, contents, options);
|
|
161
139
|
}
|
|
162
140
|
/**
|
|
163
141
|
* @deprecated Use store.delete instead.
|
|
164
142
|
*/
|
|
165
143
|
deleteLargeBlob(key) {
|
|
166
|
-
|
|
167
|
-
return this.fsCache.deleteLargeBlob(key);
|
|
168
|
-
}
|
|
169
|
-
return this.store.delete(key);
|
|
144
|
+
return this.fsCache.deleteLargeBlob(key);
|
|
170
145
|
}
|
|
171
146
|
keys() {
|
|
172
147
|
return this.store.keys();
|
package/lib/FSCache.js
CHANGED
|
@@ -25,20 +25,6 @@ function _util() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function _rust() {
|
|
29
|
-
const data = require("@atlaspack/rust");
|
|
30
|
-
_rust = function () {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _featureFlags() {
|
|
36
|
-
const data = require("@atlaspack/feature-flags");
|
|
37
|
-
_featureFlags = function () {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
28
|
function _logger() {
|
|
43
29
|
const data = _interopRequireDefault(require("@atlaspack/logger"));
|
|
44
30
|
_logger = function () {
|
|
@@ -79,10 +65,6 @@ class FSCache {
|
|
|
79
65
|
await Promise.all(dirPromises);
|
|
80
66
|
}
|
|
81
67
|
_getCachePath(cacheId) {
|
|
82
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
83
|
-
const cleanId = (0, _rust().hashString)(cacheId);
|
|
84
|
-
return _path().default.join(this.dir, cleanId.slice(0, 2), cleanId.slice(2));
|
|
85
|
-
}
|
|
86
68
|
return _path().default.join(this.dir, cacheId.slice(0, 2), cacheId.slice(2));
|
|
87
69
|
}
|
|
88
70
|
getStream(key) {
|
|
@@ -112,9 +94,6 @@ class FSCache {
|
|
|
112
94
|
}
|
|
113
95
|
}
|
|
114
96
|
#getFilePath(key, index) {
|
|
115
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
116
|
-
return _path().default.join(this.dir, `${(0, _rust().hashString)(key)}-${index}`);
|
|
117
|
-
}
|
|
118
97
|
return _path().default.join(this.dir, `${key}-${index}`);
|
|
119
98
|
}
|
|
120
99
|
async #unlinkChunks(key, index) {
|
package/lib/LMDBLiteCache.js
CHANGED
|
@@ -12,13 +12,6 @@ function _buildCache() {
|
|
|
12
12
|
};
|
|
13
13
|
return data;
|
|
14
14
|
}
|
|
15
|
-
function _featureFlags() {
|
|
16
|
-
const data = require("@atlaspack/feature-flags");
|
|
17
|
-
_featureFlags = function () {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
15
|
function _rust() {
|
|
23
16
|
const data = require("@atlaspack/rust");
|
|
24
17
|
_rust = function () {
|
|
@@ -112,7 +105,7 @@ openOptions) {
|
|
|
112
105
|
return new LmdbWrapper(new (_rust().Lmdb)({
|
|
113
106
|
path: directory,
|
|
114
107
|
asyncWrites: true,
|
|
115
|
-
mapSize: process.env.ATLASPACK_BUILD_ENV === 'test' ?
|
|
108
|
+
mapSize: process.env.ATLASPACK_BUILD_ENV === 'test' ? 256 * 1024 * 1024 : 1024 * 1024 * 1024 * 15
|
|
116
109
|
}));
|
|
117
110
|
}
|
|
118
111
|
const pipeline = (0, _util().promisify)(_stream().default.pipeline);
|
|
@@ -140,9 +133,7 @@ class LMDBLiteCache {
|
|
|
140
133
|
return this.store.lmdb;
|
|
141
134
|
}
|
|
142
135
|
async ensure() {
|
|
143
|
-
|
|
144
|
-
await this.fsCache.ensure();
|
|
145
|
-
}
|
|
136
|
+
await this.fsCache.ensure();
|
|
146
137
|
await this.fs.mkdirp(this.cacheFilesDirectory);
|
|
147
138
|
return Promise.resolve();
|
|
148
139
|
}
|
|
@@ -168,18 +159,10 @@ class LMDBLiteCache {
|
|
|
168
159
|
await this.setBlob(key, (0, _buildCache().serialize)(value));
|
|
169
160
|
}
|
|
170
161
|
getStream(key) {
|
|
171
|
-
|
|
172
|
-
return this.fs.createReadStream(_path().default.join(this.dir, key));
|
|
173
|
-
}
|
|
174
|
-
return this.fs.createReadStream(this.getFileKey(key));
|
|
162
|
+
return this.fs.createReadStream(_path().default.join(this.dir, key));
|
|
175
163
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return pipeline(stream, this.fs.createWriteStream(_path().default.join(this.dir, key)));
|
|
179
|
-
}
|
|
180
|
-
const filePath = this.getFileKey(key);
|
|
181
|
-
await this.fs.mkdirp(_path().default.dirname(filePath));
|
|
182
|
-
return pipeline(stream, this.fs.createWriteStream(filePath));
|
|
164
|
+
setStream(key, stream) {
|
|
165
|
+
return pipeline(stream, this.fs.createWriteStream(_path().default.join(this.dir, key)));
|
|
183
166
|
}
|
|
184
167
|
|
|
185
168
|
// eslint-disable-next-line require-await
|
|
@@ -200,34 +183,20 @@ class LMDBLiteCache {
|
|
|
200
183
|
return Promise.resolve(this.store.get(key));
|
|
201
184
|
}
|
|
202
185
|
hasLargeBlob(key) {
|
|
203
|
-
|
|
204
|
-
return this.fsCache.hasLargeBlob(key);
|
|
205
|
-
}
|
|
206
|
-
return this.fs.exists(this.getFileKey(key));
|
|
186
|
+
return this.fsCache.hasLargeBlob(key);
|
|
207
187
|
}
|
|
208
188
|
getLargeBlob(key) {
|
|
209
|
-
|
|
210
|
-
return this.fsCache.getLargeBlob(key);
|
|
211
|
-
}
|
|
212
|
-
return this.fs.readFile(this.getFileKey(key));
|
|
189
|
+
return this.fsCache.getLargeBlob(key);
|
|
213
190
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return this.fsCache.setLargeBlob(key, contents, options);
|
|
217
|
-
}
|
|
218
|
-
const targetPath = this.getFileKey(key);
|
|
219
|
-
await this.fs.mkdirp(_path().default.dirname(targetPath));
|
|
220
|
-
return this.fs.writeFile(targetPath, contents);
|
|
191
|
+
setLargeBlob(key, contents, options) {
|
|
192
|
+
return this.fsCache.setLargeBlob(key, contents, options);
|
|
221
193
|
}
|
|
222
194
|
|
|
223
195
|
/**
|
|
224
196
|
* @deprecated Use store.delete instead.
|
|
225
197
|
*/
|
|
226
198
|
deleteLargeBlob(key) {
|
|
227
|
-
|
|
228
|
-
return this.fsCache.deleteLargeBlob(key);
|
|
229
|
-
}
|
|
230
|
-
return this.store.delete(key);
|
|
199
|
+
return this.fsCache.deleteLargeBlob(key);
|
|
231
200
|
}
|
|
232
201
|
keys() {
|
|
233
202
|
return this.store.keys();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/cache",
|
|
3
3
|
"description": "Interface for defining caches and file-system, IDB and LMDB implementations.",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.50",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"publishConfig": {
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@atlaspack/build-cache": "2.13.
|
|
26
|
-
"@atlaspack/feature-flags": "2.
|
|
27
|
-
"@atlaspack/fs": "2.15.
|
|
28
|
-
"@atlaspack/logger": "2.14.
|
|
29
|
-
"@atlaspack/rust": "3.
|
|
30
|
-
"@atlaspack/utils": "3.3.
|
|
25
|
+
"@atlaspack/build-cache": "2.13.13",
|
|
26
|
+
"@atlaspack/feature-flags": "2.30.1",
|
|
27
|
+
"@atlaspack/fs": "2.15.50",
|
|
28
|
+
"@atlaspack/logger": "2.14.47",
|
|
29
|
+
"@atlaspack/rust": "3.24.0",
|
|
30
|
+
"@atlaspack/utils": "3.3.7",
|
|
31
31
|
"ncp": "^2.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
package/src/FSCache.ts
CHANGED
|
@@ -7,8 +7,6 @@ import stream from 'stream';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import {promisify} from 'util';
|
|
9
9
|
|
|
10
|
-
import {hashString} from '@atlaspack/rust';
|
|
11
|
-
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
12
10
|
import logger from '@atlaspack/logger';
|
|
13
11
|
import {
|
|
14
12
|
deserialize,
|
|
@@ -52,10 +50,6 @@ export class FSCache implements Cache {
|
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
_getCachePath(cacheId: string): FilePath {
|
|
55
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
56
|
-
const cleanId = hashString(cacheId);
|
|
57
|
-
return path.join(this.dir, cleanId.slice(0, 2), cleanId.slice(2));
|
|
58
|
-
}
|
|
59
53
|
return path.join(this.dir, cacheId.slice(0, 2), cacheId.slice(2));
|
|
60
54
|
}
|
|
61
55
|
|
|
@@ -95,9 +89,6 @@ export class FSCache implements Cache {
|
|
|
95
89
|
}
|
|
96
90
|
|
|
97
91
|
#getFilePath(key: string, index: number): string {
|
|
98
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
99
|
-
return path.join(this.dir, `${hashString(key)}-${index}`);
|
|
100
|
-
}
|
|
101
92
|
return path.join(this.dir, `${key}-${index}`);
|
|
102
93
|
}
|
|
103
94
|
|
package/src/LMDBLiteCache.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
registerSerializableClass,
|
|
4
4
|
serialize,
|
|
5
5
|
} from '@atlaspack/build-cache';
|
|
6
|
-
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
7
6
|
import {Lmdb} from '@atlaspack/rust';
|
|
8
7
|
import type {FilePath} from '@atlaspack/types';
|
|
9
8
|
import type {Cache} from './types';
|
|
@@ -81,7 +80,7 @@ export function open(
|
|
|
81
80
|
asyncWrites: true,
|
|
82
81
|
mapSize:
|
|
83
82
|
process.env.ATLASPACK_BUILD_ENV === 'test'
|
|
84
|
-
?
|
|
83
|
+
? 256 * 1024 * 1024
|
|
85
84
|
: 1024 * 1024 * 1024 * 15,
|
|
86
85
|
}),
|
|
87
86
|
);
|
|
@@ -126,9 +125,7 @@ export class LMDBLiteCache implements Cache {
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
async ensure(): Promise<void> {
|
|
129
|
-
|
|
130
|
-
await this.fsCache.ensure();
|
|
131
|
-
}
|
|
128
|
+
await this.fsCache.ensure();
|
|
132
129
|
await this.fs.mkdirp(this.cacheFilesDirectory);
|
|
133
130
|
return Promise.resolve();
|
|
134
131
|
}
|
|
@@ -161,24 +158,14 @@ export class LMDBLiteCache implements Cache {
|
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
getStream(key: string): Readable {
|
|
164
|
-
|
|
165
|
-
return this.fs.createReadStream(path.join(this.dir, key));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return this.fs.createReadStream(this.getFileKey(key));
|
|
161
|
+
return this.fs.createReadStream(path.join(this.dir, key));
|
|
169
162
|
}
|
|
170
163
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const filePath = this.getFileKey(key);
|
|
180
|
-
await this.fs.mkdirp(path.dirname(filePath));
|
|
181
|
-
return pipeline(stream, this.fs.createWriteStream(filePath));
|
|
164
|
+
setStream(key: string, stream: Readable): Promise<void> {
|
|
165
|
+
return pipeline(
|
|
166
|
+
stream,
|
|
167
|
+
this.fs.createWriteStream(path.join(this.dir, key)),
|
|
168
|
+
);
|
|
182
169
|
}
|
|
183
170
|
|
|
184
171
|
// eslint-disable-next-line require-await
|
|
@@ -203,45 +190,28 @@ export class LMDBLiteCache implements Cache {
|
|
|
203
190
|
}
|
|
204
191
|
|
|
205
192
|
hasLargeBlob(key: string): Promise<boolean> {
|
|
206
|
-
|
|
207
|
-
return this.fsCache.hasLargeBlob(key);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return this.fs.exists(this.getFileKey(key));
|
|
193
|
+
return this.fsCache.hasLargeBlob(key);
|
|
211
194
|
}
|
|
212
195
|
|
|
213
196
|
getLargeBlob(key: string): Promise<Buffer> {
|
|
214
|
-
|
|
215
|
-
return this.fsCache.getLargeBlob(key);
|
|
216
|
-
}
|
|
217
|
-
return this.fs.readFile(this.getFileKey(key));
|
|
197
|
+
return this.fsCache.getLargeBlob(key);
|
|
218
198
|
}
|
|
219
199
|
|
|
220
|
-
|
|
200
|
+
setLargeBlob(
|
|
221
201
|
key: string,
|
|
222
202
|
contents: Buffer | string,
|
|
223
203
|
options?: {
|
|
224
204
|
signal?: AbortSignal;
|
|
225
205
|
},
|
|
226
206
|
): Promise<void> {
|
|
227
|
-
|
|
228
|
-
return this.fsCache.setLargeBlob(key, contents, options);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const targetPath = this.getFileKey(key);
|
|
232
|
-
await this.fs.mkdirp(path.dirname(targetPath));
|
|
233
|
-
return this.fs.writeFile(targetPath, contents);
|
|
207
|
+
return this.fsCache.setLargeBlob(key, contents, options);
|
|
234
208
|
}
|
|
235
209
|
|
|
236
210
|
/**
|
|
237
211
|
* @deprecated Use store.delete instead.
|
|
238
212
|
*/
|
|
239
213
|
deleteLargeBlob(key: string): Promise<void> {
|
|
240
|
-
|
|
241
|
-
return this.fsCache.deleteLargeBlob(key);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return this.store.delete(key);
|
|
214
|
+
return this.fsCache.deleteLargeBlob(key);
|
|
245
215
|
}
|
|
246
216
|
|
|
247
217
|
keys(): Iterable<string> {
|