-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
29 lines (25 loc) · 775 Bytes
/
Copy pathApp.java
File metadata and controls
29 lines (25 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
public class App {
public static void main(String[] args) {
// TODO Auto-generated method stub
CacheLoader<String, String> loader;
loader=new CacheLoader<String, String>(){
@Override
public String load(String key) throws Exception {
//
return key.toUpperCase();
}
};
//
LoadingCache<String,String> cache;
cache= CacheBuilder.newBuilder().build(loader);
//
System.out.println("缓存的大小 : "+cache.size());
//
System.out.println("取出hello的value "+cache.getUnchecked("hello"));
System.out.println("缓存的大小 : "+cache.size());
}
}