Skip to content

Commit a377fb2

Browse files
authored
Make memory lru gc the default (#8110)
* Make memory lru gc the default * undo yarn.lock * Make memory lru gc the default * Fix tests
1 parent c04d9ef commit a377fb2

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

packages/firestore/src/api/cache_config.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ class MemoryLocalCacheImpl implements MemoryLocalCache {
6262
this._offlineComponentProvider =
6363
settings.garbageCollector._offlineComponentProvider;
6464
} else {
65-
this._offlineComponentProvider = new MemoryOfflineComponentProvider();
65+
this._offlineComponentProvider = new LruGcMemoryOfflineComponentProvider(
66+
undefined
67+
);
6668
}
6769
}
6870

packages/firestore/src/core/firestore_client.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { Aggregate } from './aggregate';
6464
import { NamedQuery } from './bundle';
6565
import {
6666
ComponentConfiguration,
67+
LruGcMemoryOfflineComponentProvider,
6768
MemoryOfflineComponentProvider,
6869
OfflineComponentProvider,
6970
OnlineComponentProvider
@@ -339,7 +340,7 @@ async function ensureOfflineComponents(
339340
logDebug(LOG_TAG, 'Using default OfflineComponentProvider');
340341
await setOfflineComponentProvider(
341342
client,
342-
new MemoryOfflineComponentProvider()
343+
new LruGcMemoryOfflineComponentProvider(undefined)
343344
);
344345
}
345346
}

packages/firestore/test/integration/api/database.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -2212,4 +2212,17 @@ apiDescribe('Database', persistence => {
22122212
});
22132213
});
22142214
});
2215+
2216+
it('Lru GC is enabled by default.', () => {
2217+
const initialData = { key: 'value' };
2218+
return withTestDb(persistence, async db => {
2219+
const docRef = doc(collection(db, 'test-collection'));
2220+
await setDoc(docRef, initialData);
2221+
return getDocFromCache(docRef).then(doc => {
2222+
expect(doc.exists()).to.be.true;
2223+
expect(doc.metadata.fromCache).to.be.true;
2224+
expect(doc.data()).to.deep.equal(initialData);
2225+
});
2226+
});
2227+
});
22152228
});

packages/firestore/test/integration/util/helpers.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ function apiDescribeInternal(
181181
message: string,
182182
testSuite: (persistence: PersistenceMode) => void
183183
): void {
184-
const persistenceModes: PersistenceMode[] = [
185-
new MemoryEagerPersistenceMode()
186-
];
184+
const persistenceModes: PersistenceMode[] = [new MemoryLruPersistenceMode()];
187185
if (isPersistenceAvailable()) {
188186
persistenceModes.push(new IndexedDbPersistenceMode());
189187
}

0 commit comments

Comments
 (0)