public class CachedLookup extends ProxyLookup
Lookup
that lazily caches the results of successful lookups performed by another instance.Constructor and Description |
---|
CachedLookup(Lookup nestedLookup)
Creates a new CachedLookup that has no limit and never clears itself.
|
CachedLookup(Lookup nestedLookup,
int maxEntries)
Creates a new limited CachedLookup that never clears itself.
|
CachedLookup(Lookup nestedLookup,
Integer maxEntries,
Scheduler resetSchedule)
Creates a new CachedLookup.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
RecordList |
get(Object... args) |
int |
getEntries()
Returns the number of cached elements.
|
long |
getHits()
Returns the number of lookup requests where the results were already cached.
|
Integer |
getMaxEntries() |
long |
getMisses()
Returns the number of lookup requests where the results were not already cached and the underlying lookup was used.
|
long |
getRequests()
Returns the number of lookup requests made on this cache (sum of
getHits() and getMisses() ). |
Scheduler |
getResetSchedule() |
String |
toString() |
close, getNestedLookup, open, setNestedLookup
public CachedLookup(Lookup nestedLookup, Integer maxEntries, Scheduler resetSchedule)
nestedLookup
- the underlying lookup to use for cache misses.maxEntries
- the maximum number of results to cache or null
if there should be no limit.resetSchedule
- the scheduler used to clear/remove all cached entries or null
if the cache should never be cleared.public CachedLookup(Lookup nestedLookup, int maxEntries)
nestedLookup
- the underlying lookup to use for cache misses.maxEntries
- the maximum number of results to cache or null
if there should be no limit.public CachedLookup(Lookup nestedLookup)
public int getEntries()
public Integer getMaxEntries()
public Scheduler getResetSchedule()
public long getHits()
public long getMisses()
public long getRequests()
getHits()
and getMisses()
).public void clear()
public RecordList get(Object... args)
get
in class ProxyLookup
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.