Java8一行搞定缓存逻辑

Show me the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
...
private static final ConcurrentHashMap<String, String> CACHE = new ConcurrentHashMap<>();


public void someMethod() {
String value = CACHE.get("key") == null ? CACHE.getOrDefault("key", CACHE.putIfAbsent("key", genValue())) : CACHE.get("key");
}

private String genValue() {
...
return value;
}
...