You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tx/operation-context.js
+19-3Lines changed: 19 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,19 @@ class ResourceCache {
118
118
returnthis.cache.has(cacheId);
119
119
}
120
120
121
+
/**
122
+
* Whether a cache is sealed. A sealed cache holds only the resources it was
123
+
* created with (at $cache-control?mode=start) and does not grow as further
124
+
* resources are seen on subsequent operations. An unsealed cache accumulates
125
+
* every resource it sees. Unknown/absent cache-ids report false.
126
+
* @param {string} cacheId - The cache identifier
127
+
* @returns {boolean}
128
+
*/
129
+
isSealed(cacheId){
130
+
constentry=this.cache.get(cacheId);
131
+
returnentry ? !!entry.sealed : false;
132
+
}
133
+
121
134
/**
122
135
* Add resources to a cache-id (merges with existing)
123
136
* @param {string} cacheId - The cache identifier
@@ -158,9 +171,11 @@ class ResourceCache {
158
171
* Set resources for a cache-id (replaces existing)
159
172
* @param {string} cacheId - The cache identifier
160
173
* @param {Array} resources - Resources to set
174
+
* @param {boolean} [sealed=false] - If true, the cache is fixed at these
175
+
* resources and will not grow when further resources are seen later.
161
176
*/
162
-
set(cacheId,resources){
163
-
this.log.info(`cache-id '${cacheId}': set (replace all) with ${resources.length} resource(s): ${resources.map(r=>this._resourceKey(r)).join(', ')}`);
177
+
set(cacheId,resources,sealed=false){
178
+
this.log.info(`cache-id '${cacheId}': set (replace all, sealed=${!!sealed}) with ${resources.length} resource(s): ${resources.map(r=>this._resourceKey(r)).join(', ')}`);
164
179
// Drop the old entry's contribution, then count the replacement.
0 commit comments