•  


Set LRU GC as the default for memory cache. by wu-hui · Pull Request #5823 · firebase/firebase-android-sdk · GitHub
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

Set LRU GC as the default for memory cache. #5823

Open
wants to merge 2 commits into
base: main
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
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class FirestoreTests : BaseTestCase() {
assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled)
assertThat(settings.isPersistenceEnabled).isFalse()
assertThat(settings.cacheSettings)
.isEqualTo(memoryCacheSettings { setGcSettings( memoryEagerGcSettings {}) })
.isEqualTo(memoryCacheSettings { setGcSettings( memoryLruGcSettings {}) })

val otherSettings = firestoreSettings {
this.setLocalCacheSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,14 @@ public void testLoadWithDocumentsThatAreAlreadyPulledFromBackend() throws Except

@Test
public void testLoadedDocumentsShouldNotBeGarbageCollectedRightAway() throws Exception {
// This test really only makes sense with memory persistence , as SQLite persistence only ever
// This test really only makes sense with memory eager GC , as LRU GCs
// lazily deletes data
db.setFirestoreSettings(
new FirebaseFirestoreSettings.Builder()
.setLocalCacheSettings(MemoryCacheSettings.newBuilder().build())
.setLocalCacheSettings(
MemoryCacheSettings.newBuilder()
.setGcSettings(MemoryLruGcSettings.newBuilder().build())
.build())
.build());

InputStream bundle = new ByteArrayInputStream(createBundle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
Expand Down Expand Up @@ -1335,8 +1334,8 @@ public void testLegacyCacheConfigForMemoryCache() {

waitFor(instance.document("coll/doc").set(map("foo", "bar")));

assertThrows(
RuntimeException.class, () -> waitFor(instance.document("coll/doc").get(Source.CACHE) ));
DocumentSnapshot snap = waitFor(instance.document("coll/doc").get(Source.CACHE));
assertEquals(map("foo", "bar"), snap.getData( ));
}

@Test
Expand All @@ -1363,8 +1362,8 @@ public void testNewCacheConfigForMemoryCache() {

waitFor(instance.document("coll/doc").set(map("foo", "bar")));

assertThrows(
RuntimeException.class, () -> waitFor(instance.document("coll/doc").get(Source.CACHE) ));
DocumentSnapshot snap = waitFor(instance.document("coll/doc").get(Source.CACHE));
assertEquals(map("foo", "bar"), snap.getData( ));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public MemoryGarbageCollectorSettings getGarbageCollectorSettings() {

/** A Builder for creating {@code MemoryCacheSettings} instance. */
public static class Builder {
private MemoryGarbageCollectorSettings gcSettings = MemoryEagerGcSettings .newBuilder().build();
private MemoryGarbageCollectorSettings gcSettings = MemoryLruGcSettings .newBuilder().build();

private Builder() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ private boolean isMemoryLruGcEnabled(FirebaseFirestoreSettings settings) {
return memorySettings.getGarbageCollectorSettings() instanceof MemoryLruGcSettings;
}

return false;
// Enabled by default.
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void builderConstructorShouldCopyAllValuesFromTheGivenSettings() {
assertEquals(settings2.getHost(), "a.b.c");
assertEquals(settings2.isSslEnabled(), false);
assertEquals(settings2.isPersistenceEnabled(), false);
assertEquals(settings2.getCacheSizeBytes(), FirebaseFirestoreSettings. CACHE_SIZE_UNLIMITED );
assertEquals(settings2.getCacheSizeBytes(), FirebaseFirestoreSettings. DEFAULT_CACHE_SIZE_BYTES );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class FirestoreTests : BaseTestCase() {
assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled)
assertThat(settings.isPersistenceEnabled).isFalse()
assertThat(settings.cacheSettings)
.isEqualTo(memoryCacheSettings { setGcSettings( memoryEagerGcSettings {}) })
.isEqualTo(memoryCacheSettings { setGcSettings( memoryLruGcSettings {}) })

val otherSettings = firestoreSettings {
this.setLocalCacheSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class FirestoreTests : BaseTestCase() {
assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled)
assertThat(settings.isPersistenceEnabled).isFalse()
assertThat(settings.cacheSettings)
.isEqualTo(memoryCacheSettings { setGcSettings( memoryEagerGcSettings {}) })
.isEqualTo(memoryCacheSettings { setGcSettings( memoryLruGcSettings {}) })

val otherSettings = firestoreSettings {
this.setLocalCacheSettings(
Expand Down
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본