Skip to content

Commit 71e7703

Browse files
committed
Add missing comments
1 parent 4b551b2 commit 71e7703

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
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 {@link 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: 27 additions & 0 deletions
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 {@link 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,6 +37,16 @@ public MemoryLruGcSettings build() {
3037
return new MemoryLruGcSettings(sizeBytes);
3138
}
3239

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 is used if unset. The minimum value to set is 1 MB.
47+
*
48+
* @return this {@code Builder} instance.
49+
*/
3350
@NonNull
3451
public Builder setSizeBytes(long size) {
3552
sizeBytes = size;
@@ -41,11 +58,21 @@ private MemoryLruGcSettings(long size) {
4158
sizeBytes = size;
4259
}
4360

61+
/** Returns a new instance of {@link MemoryLruGcSettings.Builder} with default configurations. */
4462
@NonNull
4563
public static MemoryLruGcSettings.Builder newBuilder() {
4664
return new Builder();
4765
}
4866

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

0 commit comments

Comments
 (0)