public class CalculationCache<KEY,VALUE> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<KEY,VALUE> |
cache |
protected Calculator<KEY,VALUE> |
calc |
protected Map<KEY,Exception> |
exceptionCache |
protected static org.apache.log4j.Logger |
LOG |
protected List<KEY> |
processingQueries |
protected Timer |
t |
protected long |
timeToCacheExceptions |
protected long |
timeToCacheResults |
| Constructor and Description |
|---|
CalculationCache(Calculator<KEY,VALUE> calc)
Creates a new CalculationCache object.
|
| Modifier and Type | Method and Description |
|---|---|
VALUE |
calcValue(KEY key)
Calculates the value for the given key, if required and caches it.
|
long |
getTimeToCacheExceptions()
Gets the time in milliseconds, exceptions, which were thrown during the calculation of a value, should be cached.
|
long |
getTimeToCacheResults()
Gets the time in milliseconds, the result should be cached.
|
void |
setTimeToCacheExceptions(long timeToCacheExceptions)
Sets the time in milliseconds, exceptions, which were thrown during the calculation of a value, should be cached.
|
void |
setTimeToCacheResults(long timeToCacheResults)
Sets the time in milliseconds, the result should be cached.
|
protected static final org.apache.log4j.Logger LOG
protected final Timer t
protected Calculator<KEY,VALUE> calc
protected long timeToCacheResults
protected long timeToCacheExceptions
public CalculationCache(Calculator<KEY,VALUE> calc)
calc - the calculator that should be used to calculate values of unknown keyspublic VALUE calcValue(KEY key) throws Exception
key - link queryException - if any Exception is in exceptionCachepublic long getTimeToCacheResults()
public void setTimeToCacheResults(long timeToCacheResults)
timeToCacheResults - the timeToCacheResults to setpublic long getTimeToCacheExceptions()
public void setTimeToCacheExceptions(long timeToCacheExceptions)
timeToCacheExceptions - the timeToCacheException to setCopyright © 2012–2026 cismet GmbH. All rights reserved.