public class ResponseMetadataCache
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
ResponseMetadataCache.InternalCache
Simple implementation of LinkedHashMap that overrides the
removeEldestEntry method to turn LinkedHashMap into a
LRU(ish) cache that automatically evicts old entries. |
Modifier and Type | Field and Description |
---|---|
private ResponseMetadataCache.InternalCache |
internalCache |
Constructor and Description |
---|
ResponseMetadataCache(int maxEntries)
Creates a new cache that will contain, at most the specified number of
entries.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Object obj,
ResponseMetadata metadata)
Adds a new entry to this cache, possibly evicting the oldest entry if the
cache is at its size limit.
|
ResponseMetadata |
get(java.lang.Object obj)
Returns the response metadata associated with the specified object, or
null if no metadata is associated with that object.
|
private final ResponseMetadataCache.InternalCache internalCache
public ResponseMetadataCache(int maxEntries)
maxEntries
- The maximum size of this cache.public void add(java.lang.Object obj, ResponseMetadata metadata)
obj
- The key by which to store the metadata.metadata
- The metadata for this entry.public ResponseMetadata get(java.lang.Object obj)
obj
- The key by which the desired metadata is stored.