-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from webjars/cache-improvements
Cache improvements
- Loading branch information
Showing
5 changed files
with
76 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
package org.webjars; | ||
|
||
import org.jspecify.annotations.Nullable; | ||
|
||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.Optional; | ||
import java.util.concurrent.ConcurrentMap; | ||
import java.util.function.Function; | ||
|
||
public class WebJarCacheDefault implements WebJarCache { | ||
|
||
final ConcurrentHashMap<String, String> cache; | ||
final ConcurrentMap<String, Optional<String>> cache; | ||
|
||
public WebJarCacheDefault(ConcurrentHashMap<String, String> cache) { | ||
public WebJarCacheDefault(ConcurrentMap<String, Optional<String>> cache) { | ||
this.cache = cache; | ||
} | ||
|
||
@Override | ||
public @Nullable String get(String key) { | ||
return cache.get(key); | ||
} | ||
|
||
@Override | ||
public void put(String key, String value) { | ||
cache.put(key, value); | ||
public Optional<String> computeIfAbsent(String key, Function<String, Optional<String>> function) { | ||
return cache.computeIfAbsent(key, function); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters