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.
ConcurrentTypeCache
| Modifier and Type | Class and Description |
|---|---|
| private static class | LRUTypeCache.CacheMap
Simple sub-class to get LRU cache |
| Modifier and Type | Field and Description |
|---|---|
| protected final transient LRUTypeCache. | |
| protected final int | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized ResolvedType | |
| public synchronized void | put(ResolvedTypeKey key, ResolvedType type)
Implements abstract com. |
| pack-priv Object | |
| public synchronized int |
| _map | back to summary |
|---|---|
| protected final transient LRUTypeCache. | |
| _maxEntries | back to summary |
|---|---|
| protected final int _maxEntries | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| LRUTypeCache | back to summary |
|---|---|
| public LRUTypeCache(int maxEntries) | |
| find | back to summary |
|---|---|
| public synchronized ResolvedType find(ResolvedTypeKey key) Implements abstract com.
| |
| put | back to summary |
|---|---|
| public synchronized void put(ResolvedTypeKey key, ResolvedType type) Implements abstract com.
| |
| readResolve | back to summary |
|---|---|
| pack-priv Object readResolve() | |
| size | back to summary |
|---|---|
| public synchronized int size() Implements abstract com.
| |
| Modifier and Type | Field and Description |
|---|---|
| protected final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | removeEldestEntry(Map.
The least recently inserted entry in the map, or if
this is an access-ordered map, the least recently accessed
entry. This is the entry that will be removed if this
method returns eldesttrue. If the map was empty prior
to the put or putAll invocation resulting
in this invocation, this will be the entry that was just
inserted; in other words, if the map contains a single
entry, the eldest entry is also the newest.Overrides java. true if this map should remove its eldest entry.
|
| _maxEntries | back to summary |
|---|---|
| protected final int _maxEntries | |
| CacheMap | back to summary |
|---|---|
| public CacheMap(int maxEntries) | |
| removeEldestEntry | back to summary |
|---|---|
| protected boolean removeEldestEntry(Map. Overrides java. Doc from java. Returns Sample use: this override will allow the map to grow up to 100 entries and then delete the eldest entry each time a new entry is added, maintaining a steady state of 100 entries.
private static final int MAX_ENTRIES = 100;
protected boolean removeEldestEntry(Map.Entry eldest) {
return size() > MAX_ENTRIES;
}
This method typically does not modify the map in any way,
instead allowing the map to modify itself as directed by its
return value. It is permitted for this method to modify
the map directly, but if it does so, it must return
This implementation merely returns
| |