-
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.
- Loading branch information
Showing
4 changed files
with
149 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.webjars; | ||
|
||
|
||
import org.jspecify.annotations.Nullable; | ||
|
||
/** | ||
* WebJar Locator Cache Interface | ||
* Since classpath resources are essentially immutable, the WebJarsCache does not have the concept of expiry. | ||
* Cache keys and values are Strings because that is all that is needed. | ||
*/ | ||
public interface WebJarCache { | ||
|
||
public @Nullable String get(final String key); | ||
|
||
public void put(final String key, final String value); | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.webjars; | ||
|
||
import org.jspecify.annotations.Nullable; | ||
|
||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class WebJarCacheDefault implements WebJarCache { | ||
|
||
final ConcurrentHashMap<String, String> cache; | ||
|
||
public WebJarCacheDefault(ConcurrentHashMap<String, 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); | ||
} | ||
|
||
} |
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