Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make memory lru gc the default #8110

Merged
merged 5 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/firestore/src/api/cache_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class MemoryLocalCacheImpl implements MemoryLocalCache {
this._offlineComponentProvider =
settings.garbageCollector._offlineComponentProvider;
} else {
this._offlineComponentProvider = new MemoryOfflineComponentProvider();
this._offlineComponentProvider = new LruGcMemoryOfflineComponentProvider(
undefined
);
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/firestore/src/core/firestore_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { Aggregate } from './aggregate';
import { NamedQuery } from './bundle';
import {
ComponentConfiguration,
LruGcMemoryOfflineComponentProvider,
MemoryOfflineComponentProvider,
OfflineComponentProvider,
OnlineComponentProvider
Expand Down Expand Up @@ -339,7 +340,7 @@ async function ensureOfflineComponents(
logDebug(LOG_TAG, 'Using default OfflineComponentProvider');
await setOfflineComponentProvider(
client,
new MemoryOfflineComponentProvider()
new LruGcMemoryOfflineComponentProvider(undefined)
);
}
}
Expand Down
13 changes: 13 additions & 0 deletions packages/firestore/test/integration/api/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1967,4 +1967,17 @@ apiDescribe('Database', persistence => {
});
});
});

it('Lru GC is enabled by default.', () => {
const initialData = { key: 'value' };
return withTestDb(persistence, async db => {
const docRef = doc(collection(db, 'test-collection'));
await setDoc(docRef, initialData);
return getDocFromCache(docRef).then(doc => {
expect(doc.exists()).to.be.true;
expect(doc.metadata.fromCache).to.be.true;
expect(doc.data()).to.deep.equal(initialData);
});
});
});
});
4 changes: 1 addition & 3 deletions packages/firestore/test/integration/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ function apiDescribeInternal(
message: string,
testSuite: (persistence: PersistenceMode) => void
): void {
const persistenceModes: PersistenceMode[] = [
new MemoryEagerPersistenceMode()
];
const persistenceModes: PersistenceMode[] = [new MemoryLruPersistenceMode()];
if (isPersistenceAvailable()) {
persistenceModes.push(new IndexedDbPersistenceMode());
}
Expand Down
Loading