anote-server-libs 0.7.2 → 0.7.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.
|
@@ -50,9 +50,9 @@ class MemoryCache {
|
|
|
50
50
|
else
|
|
51
51
|
return Promise.resolve(this.localCache[key]);
|
|
52
52
|
}
|
|
53
|
-
set(key, val) {
|
|
53
|
+
set(key, val, time = 15 * 60) {
|
|
54
54
|
if (this.cache)
|
|
55
|
-
return new Promise(resolve => this.cache.set(this.localKey + key, JSON.stringify(val),
|
|
55
|
+
return new Promise(resolve => this.cache.set(this.localKey + key, JSON.stringify(val), time, resolve));
|
|
56
56
|
else {
|
|
57
57
|
this.localCache[key] = val;
|
|
58
58
|
return Promise.resolve();
|
|
@@ -48,8 +48,8 @@ export class MemoryCache<T> {
|
|
|
48
48
|
else return Promise.resolve(this.localCache[key]);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
set(key: string | number, val: T): Promise<void> {
|
|
52
|
-
if(this.cache) return new Promise(resolve => this.cache.set(this.localKey + key, JSON.stringify(val),
|
|
51
|
+
set(key: string | number, val: T, time = 15 * 60): Promise<void> {
|
|
52
|
+
if(this.cache) return new Promise(resolve => this.cache.set(this.localKey + key, JSON.stringify(val), time, resolve));
|
|
53
53
|
else {
|
|
54
54
|
this.localCache[key] = val;
|
|
55
55
|
return Promise.resolve();
|
package/package.json
CHANGED
|
@@ -14,6 +14,10 @@ function withTransaction(repo, logger, previousMethod, lock, commitIfLost = true
|
|
|
14
14
|
}
|
|
15
15
|
const endTerminator = res.end.bind(res);
|
|
16
16
|
const jsonTerminator = (obj) => {
|
|
17
|
+
try {
|
|
18
|
+
res.set('Content-Type', 'application/json');
|
|
19
|
+
}
|
|
20
|
+
catch (_) { }
|
|
17
21
|
res.write((0, utils_1.jsonStringify)(obj) || '{}');
|
|
18
22
|
endTerminator();
|
|
19
23
|
};
|
|
@@ -21,6 +21,7 @@ export function withTransaction(repo: BaseModelRepository, logger: Logger, previ
|
|
|
21
21
|
}
|
|
22
22
|
const endTerminator = res.end.bind(res);
|
|
23
23
|
const jsonTerminator = (obj: any) => {
|
|
24
|
+
try { res.set('Content-Type', 'application/json'); } catch(_) {}
|
|
24
25
|
res.write(jsonStringify(obj) || '{}');
|
|
25
26
|
endTerminator();
|
|
26
27
|
};
|