Skip to content

Commit 59db66a

Browse files
committed
fix: move cache default constants to Configuration.Builder for public access
1 parent 49d8769 commit 59db66a

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

parse/src/main/java/com/parse/Parse.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,10 @@ private Configuration(Builder builder) {
602602

603603
/** Allows for simple constructing of a {@code Configuration} object. */
604604
public static final class Builder {
605+
public static final int DEFAULT_MAX_KEY_VALUE_CACHE_BYTES =
606+
ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_BYTES;
607+
public static final int DEFAULT_MAX_KEY_VALUE_CACHE_FILES =
608+
ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_FILES;
605609
private final Context context;
606610
private String applicationId;
607611
private String clientKey;
@@ -610,8 +614,8 @@ public static final class Builder {
610614
private boolean allowCustomObjectId;
611615
private OkHttpClient.Builder clientBuilder;
612616
private int maxRetries = DEFAULT_MAX_RETRIES;
613-
private int maxKeyValueCacheBytes = ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_BYTES;
614-
private int maxKeyValueCacheFiles = ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_FILES;
617+
private int maxKeyValueCacheBytes = DEFAULT_MAX_KEY_VALUE_CACHE_BYTES;
618+
private int maxKeyValueCacheFiles = DEFAULT_MAX_KEY_VALUE_CACHE_FILES;
615619

616620
/**
617621
* Initialize a bulider with a given context.
@@ -717,7 +721,7 @@ public Builder maxRetries(int maxRetries) {
717721

718722
/**
719723
* Set the maximum amount of bytes to use for the Parse cache on disk.
720-
* Defaults to {@link ParseKeyValueCache#DEFAULT_MAX_KEY_VALUE_CACHE_BYTES}.
724+
* Defaults to {@link Builder#DEFAULT_MAX_KEY_VALUE_CACHE_BYTES}.
721725
*
722726
* @param maxKeyValueCacheBytes The maximum number of bytes to use for the cache.
723727
* @return The same builder, for easy chaining.
@@ -729,7 +733,7 @@ public Builder maxKeyValueCacheBytes(int maxKeyValueCacheBytes) {
729733

730734
/**
731735
* Set the maximum number of files to store in the Parse cache on disk.
732-
* Defaults to {@link ParseKeyValueCache#DEFAULT_MAX_KEY_VALUE_CACHE_FILES}.
736+
* Defaults to {@link Builder#DEFAULT_MAX_KEY_VALUE_CACHE_FILES}.
733737
*
734738
* @param maxKeyValueCacheFiles The maximum number of files to store in the cache.
735739
* @return The same builder, for easy chaining.

parse/src/main/java/com/parse/ParseKeyValueCache.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class ParseKeyValueCache {
2222

2323
// We limit the cache to 2MB because that's about what the default browser
2424
// uses.
25-
public static final int DEFAULT_MAX_KEY_VALUE_CACHE_BYTES = 2 * 1024 * 1024;
25+
/* package */ static final int DEFAULT_MAX_KEY_VALUE_CACHE_BYTES = 2 * 1024 * 1024;
2626
// We limit to 1000 cache files to avoid taking too long while scanning the
2727
// cache
28-
public static final int DEFAULT_MAX_KEY_VALUE_CACHE_FILES = 1000;
28+
/* package */ static final int DEFAULT_MAX_KEY_VALUE_CACHE_FILES = 1000;
2929
private static final String TAG = "ParseKeyValueCache";
3030
private static final String DIR_NAME = "ParseKeyValueCache";
3131
/** Prevent multiple threads from modifying the cache at the same time. */

parse/src/test/java/com/parse/ParseKeyValueCacheTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public void testDefaultCacheConfiguration() {
100100
ParseKeyValueCache.maxKeyValueCacheBytes);
101101
assertEquals(ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_FILES,
102102
ParseKeyValueCache.maxKeyValueCacheFiles);
103+
assertEquals(ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_BYTES,
104+
Parse.Configuration.Builder.DEFAULT_MAX_KEY_VALUE_CACHE_BYTES);
105+
assertEquals(ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_FILES,
106+
Parse.Configuration.Builder.DEFAULT_MAX_KEY_VALUE_CACHE_FILES);
103107
}
104108

105109
@Test

0 commit comments

Comments
 (0)