Skip to content

Commit 73d4055

Browse files
Started adding putIfAbsent to LruAssignmentCache (#221)
* Started adding putIfAbsent to LruAssignmentCache * spotless, common v3.13 --------- Co-authored-by: Tyler Potter <[email protected]>
1 parent f7f0692 commit 73d4055

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

eppo/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ext.versions = [
6868
]
6969

7070
dependencies {
71-
api 'cloud.eppo:sdk-common-jvm:3.12.2'
71+
api 'cloud.eppo:sdk-common-jvm:3.13.0'
7272

7373
implementation 'org.slf4j:slf4j-api:2.0.17'
7474

eppo/src/main/java/cloud/eppo/android/cache/LRUAssignmentCache.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ public void put(String cacheKey, @NonNull String serializedEntry) {
2020
public String get(String cacheKey) {
2121
return cache.get(cacheKey);
2222
}
23+
24+
@Override
25+
public boolean putIfAbsent(String cacheKey, @NonNull String serializedEntry) {
26+
boolean hadNoPreviousEntry;
27+
synchronized (cache) {
28+
String entry = cache.get(cacheKey);
29+
hadNoPreviousEntry = entry == null;
30+
if (hadNoPreviousEntry) {
31+
cache.put(cacheKey, serializedEntry);
32+
}
33+
}
34+
return hadNoPreviousEntry;
35+
}
2336
});
2437
}
2538
}

0 commit comments

Comments
 (0)