Skip to content

Commit 77ab6f7

Browse files
authored
Fix return type of Builder.set (#5161)
* Fix return type of Builder.set * Add missing comments * Address feedback
1 parent 9471221 commit 77ab6f7

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

firebase-firestore/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ package com.google.firebase.firestore {
345345

346346
public static class MemoryLruGcSettings.Builder {
347347
method @NonNull public com.google.firebase.firestore.MemoryLruGcSettings build();
348-
method public void setSizeBytes(long);
348+
method @NonNull public com.google.firebase.firestore.MemoryLruGcSettings.Builder setSizeBytes(long);
349349
}
350350

351351
public enum MetadataChanges {

firebase-firestore/src/main/java/com/google/firebase/firestore/MemoryEagerGcSettings.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@
1717
import androidx.annotation.NonNull;
1818
import androidx.annotation.Nullable;
1919

20+
/**
21+
* Configures the SDK to use an eager garbage collector for memory cache. The eager garbage
22+
* collector will attempt to remove any documents from SDK's memory cache as soon as it is no longer
23+
* used.
24+
*
25+
* <p>This is the default garbage collector unless specified explicitly otherwise.
26+
*
27+
* <p>To use, create an instance using {@code MemoryEagerGcSettings#newBuilder().build()}, then set
28+
* the instance to {@code MemoryCacheSettings.Builder#setGcSettings}, and use the built {@code
29+
* MemoryCacheSettings} instance to configure the Firestore SDK.
30+
*/
2031
public final class MemoryEagerGcSettings implements MemoryGarbageCollectorSettings {
2132
private MemoryEagerGcSettings() {}
2233

firebase-firestore/src/main/java/com/google/firebase/firestore/MemoryLruGcSettings.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616

1717
import androidx.annotation.NonNull;
1818

19+
/**
20+
* Configures the SDK to use a Least-Recently-Used garbage collector for memory cache.
21+
*
22+
* <p>To use, create an instance using {@code MemoryLruGcSettings#newBuilder().build()}, then set
23+
* the instance to {@code MemoryCacheSettings.Builder#setGcSettings}, and use the built {@code
24+
* MemoryCacheSettings} instance to configure the Firestore SDK.
25+
*/
1926
public final class MemoryLruGcSettings implements MemoryGarbageCollectorSettings {
2027

2128
private long sizeBytes;
@@ -30,20 +37,43 @@ public MemoryLruGcSettings build() {
3037
return new MemoryLruGcSettings(sizeBytes);
3138
}
3239

33-
public void setSizeBytes(long size) {
40+
/**
41+
* Sets an approximate cache size threshold for the memory cache. If the cache grows beyond this
42+
* size, Firestore SDK will start removing data that hasn't been recently used. The size is not
43+
* a guarantee that the cache will stay below that size, only that if the cache exceeds the
44+
* given size, cleanup will be attempted.
45+
*
46+
* <p>A default size of 100MB (100 * 1024 * 1024) is used if unset. The minimum value to set is
47+
* 1 MB (1024 * 1024).
48+
*
49+
* @return this {@code Builder} instance.
50+
*/
51+
@NonNull
52+
public Builder setSizeBytes(long size) {
3453
sizeBytes = size;
54+
return this;
3555
}
3656
}
3757

3858
private MemoryLruGcSettings(long size) {
3959
sizeBytes = size;
4060
}
4161

62+
/** Returns a new instance of {@link MemoryLruGcSettings.Builder} with default configurations. */
4263
@NonNull
4364
public static MemoryLruGcSettings.Builder newBuilder() {
4465
return new Builder();
4566
}
4667

68+
/**
69+
* Returns cache size threshold for the memory cache. If the cache grows beyond this size,
70+
* Firestore SDK will start removing data that hasn't been recently used. The size is not a
71+
* guarantee that the cache will stay below that size, only that if the cache exceeds the given
72+
* size, cleanup will be attempted.
73+
*
74+
* <p>By default, memory LRU cache is enabled with a cache size of 100MB (100 * 1024 * 1024). The
75+
* minimum value is 1 MB (1024 * 1024).
76+
*/
4777
public long getSizeBytes() {
4878
return sizeBytes;
4979
}

0 commit comments

Comments
 (0)