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 accessedResolvedType
instances. Uses "least-recently used" eviction algorithm (viaLinkedHashMap
used 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
ResolvedTypeCache
implementations, 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 class
LRUTypeCache.CacheMap
Simple sub-class to get LRU cache
-
Field Summary
Fields Modifier and Type Field Description protected LRUTypeCache.CacheMap
_map
protected int
_maxEntries
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description LRUTypeCache(int maxEntries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResolvedType
find(ResolvedTypeKey key)
void
put(ResolvedTypeKey key, ResolvedType type)
(package private) java.lang.Object
readResolve()
int
size()
-
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:
find
in classResolvedTypeCache
-
size
public int size()
- Specified by:
size
in classResolvedTypeCache
-
put
public void put(ResolvedTypeKey key, ResolvedType type)
- Specified by:
put
in classResolvedTypeCache
-
-