This commit is contained in:
Gsllchb 2018-05-25 21:29:23 +08:00 committed by GitHub
parent 3cfab5caf2
commit 77afe7bb65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,7 +191,7 @@ WeakHashMap 的 Entry 继承自 WeakReference主要用来实现缓存。
private static class Entry<K,V> extends WeakReference<Object> implements Map.Entry<K,V> private static class Entry<K,V> extends WeakReference<Object> implements Map.Entry<K,V>
``` ```
Tomcat 中的 ConcurrentCache 就使用了 WeakHashMap 来实现缓存功能。ConcurrentCache 采取的是分代缓存,经常使用的对象放入 eden 中,而不常用的对象放入 longterm。eden 使用 ConcurrentHashMa 实现longterm 使用 WeakHashMap保证了不常使用的对象容易被回收。 Tomcat 中的 ConcurrentCache 就使用了 WeakHashMap 来实现缓存功能。ConcurrentCache 采取的是分代缓存,经常使用的对象放入 eden 中,而不常用的对象放入 longterm。eden 使用 ConcurrentHashMap 实现longterm 使用 WeakHashMap保证了不常使用的对象容易被回收。
```java ```java
public final class ConcurrentCache<K, V> { public final class ConcurrentCache<K, V> {