Skip to content

Commit e83ab0b

Browse files
authored
Merge 51cedc5 into 6d31930
2 parents 6d31930 + 51cedc5 commit e83ab0b

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

packages/firestore/src/api/cache_config.ts

Lines changed: 3 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,4 +1967,17 @@ apiDescribe('Database', persistence => {
19671967
});
19681968
});
19691969
});
1970+
1971+
it('Lru GC is enabled by default.', () => {
1972+
const initialData = { key: 'value' };
1973+
return withTestDb(persistence, async db => {
1974+
const docRef = doc(collection(db, 'test-collection'));
1975+
await setDoc(docRef, initialData);
1976+
return getDocFromCache(docRef).then(doc => {
1977+
expect(doc.exists()).to.be.true;
1978+
expect(doc.metadata.fromCache).to.be.true;
1979+
expect(doc.data()).to.deep.equal(initialData);
1980+
});
1981+
});
1982+
});
19701983
});

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

Lines changed: 1 addition & 3 deletions
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)