Package com.fasterxml.classmate.util
Class LRUTypeCache
- java.lang.Object
-
- com.fasterxml.classmate.util.ResolvedTypeCache
-
- com.fasterxml.classmate.util.LRUTypeCache
-
- All Implemented Interfaces:
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
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.classmate.util.LRUTypeCache.CacheMap
_map
protected int
_maxEntries
-
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)
int
size()
-
Methods inherited from class com.fasterxml.classmate.util.ResolvedTypeCache
_addForTest, concurrentCache, key, key, lruCache
-
-
-
-
Method Detail
-
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
-
-