Class CachedLookup
java.lang.Object
com.northconcepts.datapipeline.transform.lookup.Lookup
com.northconcepts.datapipeline.transform.lookup.ProxyLookup
com.northconcepts.datapipeline.transform.lookup.CachedLookup
A
Lookup that lazily caches the results of successful lookups performed by another instance.-
Constructor Summary
ConstructorsConstructorDescriptionCachedLookup(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all cached results; the hit and miss counts are not reset.Returns the records that match the supplied composite lookup key.intReturns the number of cached elements.longgetHits()Returns the number of lookup requests where the results were already cached.Returns the maximum number of results to cache ornullif there is no limit.longReturns the number of lookup requests where the results were not already cached and the underlying lookup was used.longReturns the number of lookup requests made on this cache (sum ofgetHits()andgetMisses()).Returns the schedule for clearing all cached results ornullif the cache is never cleared.toString()Methods inherited from class com.northconcepts.datapipeline.transform.lookup.ProxyLookup
close, getNestedLookup, open, setNestedLookup
-
Constructor Details
-
CachedLookup
Creates a new CachedLookup.- Parameters:
nestedLookup- the underlying lookup to use for cache misses.maxEntries- the maximum number of results to cache ornullif there should be no limit.resetSchedule- the scheduler used to clear/remove all cached entries ornullif the cache should never be cleared.
-
CachedLookup
Creates a new limited CachedLookup that never clears itself.- Parameters:
nestedLookup- the underlying lookup to use for cache misses.maxEntries- the maximum number of results to cache ornullif there should be no limit.
-
CachedLookup
Creates a new CachedLookup that has no limit and never clears itself.
-
-
Method Details
-
getEntries
public int getEntries()Returns the number of cached elements. -
getMaxEntries
Returns the maximum number of results to cache ornullif there is no limit. -
getResetSchedule
Returns the schedule for clearing all cached results ornullif the cache is never cleared. -
getHits
public long getHits()Returns the number of lookup requests where the results were already cached. -
getMisses
public long getMisses()Returns the number of lookup requests where the results were not already cached and the underlying lookup was used. -
getRequests
public long getRequests()Returns the number of lookup requests made on this cache (sum ofgetHits()andgetMisses()). -
clear
public void clear()Removes all cached results; the hit and miss counts are not reset. -
get
Description copied from class:LookupReturns the records that match the supplied composite lookup key.Contract for subclasses (see also
docs/authoring/Lookup.md):- Called once per source record by
LookupTransformer; keep it fast. - Return an empty
RecordListwhen no match is found.nullis also tolerated byLookupTransformerfor backward compatibility, but new code should prefer an empty list for clearer semantics. - Do not mutate the supplied
keys; they are owned by the caller.
- Overrides:
getin classProxyLookup
- Called once per source record by
-
toString
-