16
16
17
17
import androidx .annotation .NonNull ;
18
18
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
+ */
19
26
public final class MemoryLruGcSettings implements MemoryGarbageCollectorSettings {
20
27
21
28
private long sizeBytes ;
@@ -30,6 +37,16 @@ public MemoryLruGcSettings build() {
30
37
return new MemoryLruGcSettings (sizeBytes );
31
38
}
32
39
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
+ */
33
50
@ NonNull
34
51
public Builder setSizeBytes (long size ) {
35
52
sizeBytes = size ;
@@ -41,11 +58,21 @@ private MemoryLruGcSettings(long size) {
41
58
sizeBytes = size ;
42
59
}
43
60
61
+ /** Returns a new instance of {@link MemoryLruGcSettings.Builder} with default configurations. */
44
62
@ NonNull
45
63
public static MemoryLruGcSettings .Builder newBuilder () {
46
64
return new Builder ();
47
65
}
48
66
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
+ */
49
76
public long getSizeBytes () {
50
77
return sizeBytes ;
51
78
}
0 commit comments