File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,9 @@ class MemoryLocalCacheImpl implements MemoryLocalCache {
62
62
this . _offlineComponentProvider =
63
63
settings . garbageCollector . _offlineComponentProvider ;
64
64
} else {
65
- this . _offlineComponentProvider = new MemoryOfflineComponentProvider ( ) ;
65
+ this . _offlineComponentProvider = new LruGcMemoryOfflineComponentProvider (
66
+ undefined
67
+ ) ;
66
68
}
67
69
}
68
70
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ import { Aggregate } from './aggregate';
64
64
import { NamedQuery } from './bundle' ;
65
65
import {
66
66
ComponentConfiguration ,
67
+ LruGcMemoryOfflineComponentProvider ,
67
68
MemoryOfflineComponentProvider ,
68
69
OfflineComponentProvider ,
69
70
OnlineComponentProvider
@@ -339,7 +340,7 @@ async function ensureOfflineComponents(
339
340
logDebug ( LOG_TAG , 'Using default OfflineComponentProvider' ) ;
340
341
await setOfflineComponentProvider (
341
342
client ,
342
- new MemoryOfflineComponentProvider ( )
343
+ new LruGcMemoryOfflineComponentProvider ( undefined )
343
344
) ;
344
345
}
345
346
}
Original file line number Diff line number Diff line change @@ -254,6 +254,51 @@ export function withTestDb(
254
254
} ) ;
255
255
}
256
256
257
+ export function withEnsuredEagerGcTestDb (
258
+ fn : ( db : Firestore ) => Promise < void >
259
+ ) : Promise < void > {
260
+ const newSettings = { ...DEFAULT_SETTINGS } ;
261
+ newSettings . localCache = memoryLocalCache ( {
262
+ garbageCollector : memoryEagerGarbageCollector ( )
263
+ } ) ;
264
+ return withTestDbsSettings (
265
+ false ,
266
+ DEFAULT_PROJECT_ID ,
267
+ newSettings ,
268
+ 1 ,
269
+ async ( [ db ] ) => {
270
+ return fn ( db ) ;
271
+ }
272
+ ) ;
273
+ }
274
+
275
+ export function withEnsuredLruGcTestDb (
276
+ persistence : boolean ,
277
+ fn : ( db : Firestore ) => Promise < void >
278
+ ) : Promise < void > {
279
+ const newSettings = { ...DEFAULT_SETTINGS } ;
280
+ if ( persistence ) {
281
+ newSettings . localCache = persistentLocalCache ( {
282
+ cacheSizeBytes : 1 * 1024 * 1024
283
+ } ) ;
284
+ } else {
285
+ newSettings . localCache = memoryLocalCache ( {
286
+ garbageCollector : memoryLruGarbageCollector ( {
287
+ cacheSizeBytes : 1 * 1024 * 1024
288
+ } )
289
+ } ) ;
290
+ }
291
+ return withTestDbsSettings (
292
+ persistence ,
293
+ DEFAULT_PROJECT_ID ,
294
+ newSettings ,
295
+ 1 ,
296
+ async ( [ db ] ) => {
297
+ return fn ( db ) ;
298
+ }
299
+ ) ;
300
+ }
301
+
257
302
/** Runs provided fn with a db for an alternate project id. */
258
303
export function withAlternateTestDb (
259
304
persistence : PersistenceMode | typeof PERSISTENCE_MODE_UNSPECIFIED ,
You can’t perform that action at this time.
0 commit comments