@snowtop/ent 0.1.16-test1 → 0.1.17
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/core/base.d.ts +1 -0
- package/core/context.d.ts +5 -0
- package/core/context.js +10 -2
- package/graphql/graphql.d.ts +1 -0
- package/package.json +1 -1
package/core/base.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ interface cache {
|
|
|
35
35
|
primeCache(options: QueryOptions, rows: Data[]): void;
|
|
36
36
|
primeCache(options: QueryOptions, rows: Data): void;
|
|
37
37
|
clearCache(): void;
|
|
38
|
+
reset(): void;
|
|
38
39
|
}
|
|
39
40
|
export interface Context<TViewer extends Viewer = Viewer> {
|
|
40
41
|
getViewer(): TViewer;
|
package/core/context.d.ts
CHANGED
|
@@ -22,4 +22,9 @@ export declare class ContextCache {
|
|
|
22
22
|
primeCache(options: QueryOptions, rows: Data[]): void;
|
|
23
23
|
primeCache(options: QueryOptions, rows: Data): void;
|
|
24
24
|
clearCache(): void;
|
|
25
|
+
/**
|
|
26
|
+
* reset clears the cache and resets the discarded loaders
|
|
27
|
+
* this is used in long-running things like tests or websocket connections where the same Context or ContextCache is being used repeatedly
|
|
28
|
+
*/
|
|
29
|
+
reset(): void;
|
|
25
30
|
}
|
package/core/context.js
CHANGED
|
@@ -96,16 +96,24 @@ class ContextCache {
|
|
|
96
96
|
this.discardedLoaders.forEach((l) => l.clearAll());
|
|
97
97
|
for (const [_key, loader] of this.loaders) {
|
|
98
98
|
loader.clearAll();
|
|
99
|
-
|
|
99
|
+
this.discardedLoaders.push(loader);
|
|
100
100
|
}
|
|
101
101
|
for (const [_key, loader] of this.loaderWithLoadMany) {
|
|
102
102
|
loader.clearAll();
|
|
103
|
-
|
|
103
|
+
this.discardedLoaders.push(loader);
|
|
104
104
|
}
|
|
105
105
|
this.loaders.clear();
|
|
106
106
|
this.loaderWithLoadMany.clear();
|
|
107
107
|
this.itemMap.clear();
|
|
108
108
|
this.listMap.clear();
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* reset clears the cache and resets the discarded loaders
|
|
112
|
+
* this is used in long-running things like tests or websocket connections where the same Context or ContextCache is being used repeatedly
|
|
113
|
+
*/
|
|
114
|
+
reset() {
|
|
115
|
+
this.clearCache();
|
|
116
|
+
this.discardedLoaders = [];
|
|
117
|
+
}
|
|
110
118
|
}
|
|
111
119
|
exports.ContextCache = ContextCache;
|
package/graphql/graphql.d.ts
CHANGED