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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/firestore/src/api/cache_config.ts
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
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
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
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