@atlaspack/cache 3.0.2-canary.2 → 3.0.2-canary.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.
- package/CHANGELOG.md +14 -0
- package/lib/LMDBLiteCache.js +45 -10
- package/package.json +8 -7
- package/src/LMDBLiteCache.js +41 -10
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @atlaspack/cache
|
2
2
|
|
3
|
+
## 3.1.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- [#525](https://github.com/atlassian-labs/atlaspack/pull/525) [`cb9da16`](https://github.com/atlassian-labs/atlaspack/commit/cb9da16fb2648e7f53c64df0313f60d5fb8970cc) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix issues with large blob cache writes, run cache writes in a write transaction
|
8
|
+
|
9
|
+
### Patch Changes
|
10
|
+
|
11
|
+
- Updated dependencies [[`1a2c14c`](https://github.com/atlassian-labs/atlaspack/commit/1a2c14c3cd4587551cc12e94d0680c8b71ea12bf), [`cb9da16`](https://github.com/atlassian-labs/atlaspack/commit/cb9da16fb2648e7f53c64df0313f60d5fb8970cc)]:
|
12
|
+
- @atlaspack/rust@3.2.0
|
13
|
+
- @atlaspack/fs@2.14.4
|
14
|
+
- @atlaspack/logger@2.14.4
|
15
|
+
- @atlaspack/utils@2.14.4
|
16
|
+
|
3
17
|
## 3.0.1
|
4
18
|
|
5
19
|
### Patch Changes
|
package/lib/LMDBLiteCache.js
CHANGED
@@ -12,6 +12,13 @@ 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
|
+
}
|
15
22
|
function _rust() {
|
16
23
|
const data = require("@atlaspack/rust");
|
17
24
|
_rust = function () {
|
@@ -60,6 +67,12 @@ class LmdbWrapper {
|
|
60
67
|
this.lmdb.close();
|
61
68
|
};
|
62
69
|
}
|
70
|
+
has(key) {
|
71
|
+
return this.lmdb.hasSync(key);
|
72
|
+
}
|
73
|
+
async delete(key) {
|
74
|
+
await this.lmdb.delete(key);
|
75
|
+
}
|
63
76
|
get(key) {
|
64
77
|
return this.lmdb.getSync(key);
|
65
78
|
}
|
@@ -99,7 +112,9 @@ class LMDBLiteCache {
|
|
99
112
|
return this.store.lmdb;
|
100
113
|
}
|
101
114
|
async ensure() {
|
102
|
-
|
115
|
+
if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
116
|
+
await this.fsCache.ensure();
|
117
|
+
}
|
103
118
|
return Promise.resolve();
|
104
119
|
}
|
105
120
|
serialize() {
|
@@ -111,7 +126,7 @@ class LMDBLiteCache {
|
|
111
126
|
return new LMDBLiteCache(cache.dir);
|
112
127
|
}
|
113
128
|
has(key) {
|
114
|
-
return Promise.resolve(this.store.
|
129
|
+
return Promise.resolve(this.store.has(key));
|
115
130
|
}
|
116
131
|
get(key) {
|
117
132
|
let data = this.store.get(key);
|
@@ -151,20 +166,40 @@ class LMDBLiteCache {
|
|
151
166
|
return _path().default.join(this.dir, `${key}-${index}`);
|
152
167
|
}
|
153
168
|
hasLargeBlob(key) {
|
154
|
-
|
169
|
+
if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
170
|
+
return this.fsCache.hasLargeBlob(key);
|
171
|
+
}
|
172
|
+
return this.has(key);
|
155
173
|
}
|
156
174
|
|
157
|
-
|
158
|
-
|
159
|
-
|
175
|
+
/**
|
176
|
+
* @deprecated Use getBlob instead.
|
177
|
+
*/
|
178
|
+
getLargeBlob(key) {
|
179
|
+
if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
180
|
+
return this.fsCache.getLargeBlob(key);
|
181
|
+
}
|
182
|
+
return Promise.resolve(this.getBlobSync(key));
|
160
183
|
}
|
161
184
|
|
162
|
-
|
163
|
-
|
164
|
-
|
185
|
+
/**
|
186
|
+
* @deprecated Use setBlob instead.
|
187
|
+
*/
|
188
|
+
setLargeBlob(key, contents, options) {
|
189
|
+
if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
190
|
+
return this.fsCache.setLargeBlob(key, contents, options);
|
191
|
+
}
|
192
|
+
return this.setBlob(key, contents);
|
165
193
|
}
|
194
|
+
|
195
|
+
/**
|
196
|
+
* @deprecated Use store.delete instead.
|
197
|
+
*/
|
166
198
|
deleteLargeBlob(key) {
|
167
|
-
|
199
|
+
if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
200
|
+
return this.fsCache.deleteLargeBlob(key);
|
201
|
+
}
|
202
|
+
return this.store.delete(key);
|
168
203
|
}
|
169
204
|
refresh() {
|
170
205
|
// Reset the read transaction for the store. This guarantees that
|
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.0.2-canary.
|
4
|
+
"version": "3.0.2-canary.4+9dee30885",
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
6
6
|
"type": "commonjs",
|
7
7
|
"publishConfig": {
|
@@ -23,11 +23,12 @@
|
|
23
23
|
"check-ts": "tsc --noEmit index.d.ts"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@atlaspack/build-cache": "2.13.3-canary.
|
27
|
-
"@atlaspack/
|
28
|
-
"@atlaspack/
|
29
|
-
"@atlaspack/
|
30
|
-
"@atlaspack/
|
26
|
+
"@atlaspack/build-cache": "2.13.3-canary.67+9dee30885",
|
27
|
+
"@atlaspack/feature-flags": "2.14.1-canary.67+9dee30885",
|
28
|
+
"@atlaspack/fs": "2.14.4-canary.4+9dee30885",
|
29
|
+
"@atlaspack/logger": "2.14.4-canary.4+9dee30885",
|
30
|
+
"@atlaspack/rust": "3.1.2-canary.4+9dee30885",
|
31
|
+
"@atlaspack/utils": "2.14.4-canary.4+9dee30885"
|
31
32
|
},
|
32
33
|
"devDependencies": {
|
33
34
|
"idb": "^5.0.8"
|
@@ -35,5 +36,5 @@
|
|
35
36
|
"browser": {
|
36
37
|
"./src/IDBCache.js": "./src/IDBCache.browser.js"
|
37
38
|
},
|
38
|
-
"gitHead": "
|
39
|
+
"gitHead": "9dee30885fc8c0f3654d54151d75f1e89907dafd"
|
39
40
|
}
|
package/src/LMDBLiteCache.js
CHANGED
@@ -5,6 +5,7 @@ import {
|
|
5
5
|
registerSerializableClass,
|
6
6
|
serialize,
|
7
7
|
} from '@atlaspack/build-cache';
|
8
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
8
9
|
import {Lmdb} from '@atlaspack/rust';
|
9
10
|
import type {FilePath} from '@atlaspack/types';
|
10
11
|
import type {Cache} from './types';
|
@@ -41,6 +42,14 @@ export class LmdbWrapper {
|
|
41
42
|
};
|
42
43
|
}
|
43
44
|
|
45
|
+
has(key: string): boolean {
|
46
|
+
return this.lmdb.hasSync(key);
|
47
|
+
}
|
48
|
+
|
49
|
+
async delete(key: string): Promise<void> {
|
50
|
+
await this.lmdb.delete(key);
|
51
|
+
}
|
52
|
+
|
44
53
|
get(key: string): Buffer | null {
|
45
54
|
return this.lmdb.getSync(key);
|
46
55
|
}
|
@@ -105,7 +114,9 @@ export class LMDBLiteCache implements Cache {
|
|
105
114
|
}
|
106
115
|
|
107
116
|
async ensure(): Promise<void> {
|
108
|
-
|
117
|
+
if (!getFeatureFlag('cachePerformanceImprovements')) {
|
118
|
+
await this.fsCache.ensure();
|
119
|
+
}
|
109
120
|
return Promise.resolve();
|
110
121
|
}
|
111
122
|
|
@@ -120,7 +131,7 @@ export class LMDBLiteCache implements Cache {
|
|
120
131
|
}
|
121
132
|
|
122
133
|
has(key: string): Promise<boolean> {
|
123
|
-
return Promise.resolve(this.store.
|
134
|
+
return Promise.resolve(this.store.has(key));
|
124
135
|
}
|
125
136
|
|
126
137
|
get<T>(key: string): Promise<?T> {
|
@@ -173,25 +184,45 @@ export class LMDBLiteCache implements Cache {
|
|
173
184
|
}
|
174
185
|
|
175
186
|
hasLargeBlob(key: string): Promise<boolean> {
|
176
|
-
|
187
|
+
if (!getFeatureFlag('cachePerformanceImprovements')) {
|
188
|
+
return this.fsCache.hasLargeBlob(key);
|
189
|
+
}
|
190
|
+
return this.has(key);
|
177
191
|
}
|
178
192
|
|
179
|
-
|
180
|
-
|
181
|
-
|
193
|
+
/**
|
194
|
+
* @deprecated Use getBlob instead.
|
195
|
+
*/
|
196
|
+
getLargeBlob(key: string): Promise<Buffer> {
|
197
|
+
if (!getFeatureFlag('cachePerformanceImprovements')) {
|
198
|
+
return this.fsCache.getLargeBlob(key);
|
199
|
+
}
|
200
|
+
return Promise.resolve(this.getBlobSync(key));
|
182
201
|
}
|
183
202
|
|
184
|
-
|
185
|
-
|
203
|
+
/**
|
204
|
+
* @deprecated Use setBlob instead.
|
205
|
+
*/
|
206
|
+
setLargeBlob(
|
186
207
|
key: string,
|
187
208
|
contents: Buffer | string,
|
188
209
|
options?: {|signal?: AbortSignal|},
|
189
210
|
): Promise<void> {
|
190
|
-
|
211
|
+
if (!getFeatureFlag('cachePerformanceImprovements')) {
|
212
|
+
return this.fsCache.setLargeBlob(key, contents, options);
|
213
|
+
}
|
214
|
+
return this.setBlob(key, contents);
|
191
215
|
}
|
192
216
|
|
217
|
+
/**
|
218
|
+
* @deprecated Use store.delete instead.
|
219
|
+
*/
|
193
220
|
deleteLargeBlob(key: string): Promise<void> {
|
194
|
-
|
221
|
+
if (!getFeatureFlag('cachePerformanceImprovements')) {
|
222
|
+
return this.fsCache.deleteLargeBlob(key);
|
223
|
+
}
|
224
|
+
|
225
|
+
return this.store.delete(key);
|
195
226
|
}
|
196
227
|
|
197
228
|
refresh(): void {
|