Package com.fasterxml.classmate.util
Class LRUTypeCache
java.lang.Object
com.fasterxml.classmate.util.ResolvedTypeCache
com.fasterxml.classmate.util.LRUTypeCache
- All Implemented Interfaces:
Serializable
Simple cache used for storing up to specified number of most recently accessed
ResolvedType
instances. Uses "least-recently used" eviction algorithm
(via LinkedHashMap
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Simple sub-class to get LRU cache -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final LRUTypeCache.CacheMap
protected final int
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfind
(ResolvedTypeKey key) void
put
(ResolvedTypeKey key, ResolvedType type) (package private) Object
int
size()
Methods inherited from class com.fasterxml.classmate.util.ResolvedTypeCache
_addForTest, concurrentCache, key, key, lruCache
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
_maxEntries
protected final int _maxEntries -
_map
-
-
Constructor Details
-
LRUTypeCache
public LRUTypeCache(int maxEntries)
-
-
Method Details
-
readResolve
Object readResolve() -
find
- Specified by:
find
in classResolvedTypeCache
-
size
public int size()- Specified by:
size
in classResolvedTypeCache
-
put
- Specified by:
put
in classResolvedTypeCache
-