Package com.fasterxml.classmate.util
Class LRUTypeCache
- java.lang.Object
-
- com.fasterxml.classmate.util.ResolvedTypeCache
-
- com.fasterxml.classmate.util.LRUTypeCache
-
- All Implemented Interfaces:
java.io.Serializable
public class LRUTypeCache extends ResolvedTypeCache
Simple cache used for storing up to specified number of most recently accessedResolvedTypeinstances. Uses "least-recently used" eviction algorithm (viaLinkedHashMapused internally) which optimized retention, but requires full synchronization as read operation also has to modify internal state to maintain LRU aspects. This means that it works well in optimizing access patterns, by keeping most recently accessed types in cache, but may not well work well for highly concurrent cases due to synchronization overhead.Like all
ResolvedTypeCacheimplementations, access is thread-safe and caller need not (and should not) use additional synchronization.- Since:
- 1.4
- See Also:
ConcurrentTypeCache, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classLRUTypeCache.CacheMapSimple sub-class to get LRU cache
-
Field Summary
Fields Modifier and Type Field Description protected LRUTypeCache.CacheMap_mapprotected int_maxEntriesprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description LRUTypeCache(int maxEntries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResolvedTypefind(ResolvedTypeKey key)voidput(ResolvedTypeKey key, ResolvedType type)(package private) java.lang.ObjectreadResolve()intsize()-
Methods inherited from class com.fasterxml.classmate.util.ResolvedTypeCache
_addForTest, concurrentCache, key, key, lruCache
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
_maxEntries
protected final int _maxEntries
-
_map
protected final transient LRUTypeCache.CacheMap _map
-
-
Method Detail
-
readResolve
java.lang.Object readResolve()
-
find
public ResolvedType find(ResolvedTypeKey key)
- Specified by:
findin classResolvedTypeCache
-
size
public int size()
- Specified by:
sizein classResolvedTypeCache
-
put
public void put(ResolvedTypeKey key, ResolvedType type)
- Specified by:
putin classResolvedTypeCache
-
-