Class AsymmetricKeyCache
- All Implemented Interfaces:
Serializable
The key cache supporting AsymmetricKey.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove all elements from the cache.doubleGet the total cache fill grade in percent.doubleGet the size of the lowest cache in fraction of percent.Gets a set of parameter which should be calculated next.booleanisEmpty()Check if the cache is empty.voidLoads the cache from the specified filename.voidAdds the keys in the specified file to the cache.peek(AlgorithmParameter parameter) Gets a precalculated key from the cache without removing it.pull(AlgorithmParameter parameter) Gets a precalculated key from the cache.voidpush(AsymmetricKey key) store a precalculated key into the cache.voidremoveCacheElement(int index) Remove the specified key type from cache.voidrequestCacheIncrease(AlgorithmParameter parameter) Increase the cache size for the specified parameter set.voidsetCacheSize(int index, int value) Set the expected size of the cache.voidsetCalcTime(AlgorithmParameter ap, long millis) Sets the time for a calculation with the specified parameter.voidDumps cache stats to the logger.voidStores the cache to the specified filename for later usage.
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
esr
-
-
Constructor Details
-
AsymmetricKeyCache
public AsymmetricKeyCache()
-
-
Method Details
-
store
Stores the cache to the specified filename for later usage.
- Parameters:
filename- the filename to store to (will replace an existing file)- Throws:
IOException- if writing of file fails
-
load
Loads the cache from the specified filename.
- Parameters:
filename- the filename to read from- Throws:
IOException- if reading of file fails
-
merge
Adds the keys in the specified file to the cache.
- Parameters:
filename- the filename of the cache to merge- Throws:
IOException- if reading of the file fails
-
setCalcTime
Sets the time for a calculation with the specified parameter.
- Parameters:
ap- parameter setmillis- the time in milliseconds it takes on average to calculate the key
-
pull
Gets a precalculated key from the cache.
- Parameters:
parameter- the parameter set requested- Returns:
- the key or null if no such key is available in the cache
-
peek
Gets a precalculated key from the cache without removing it.
- Parameters:
parameter- the parameter set requested- Returns:
- the key or null if no such key is available in the cache
-
push
store a precalculated key into the cache.
- Parameters:
key- the key to be stored
-
requestCacheIncrease
Increase the cache size for the specified parameter set.
- Parameters:
parameter- the parameter set to be increased
-
getSpeculativeParameter
Gets a set of parameter which should be calculated next.
- Returns:
- the parameter set
-
getLowestCacheSize
public double getLowestCacheSize()Get the size of the lowest cache in fraction of percent.
- Returns:
- the fill state of the lowest cache (bounds 0..1)
-
getCacheFillGrade
public double getCacheFillGrade()Get the total cache fill grade in percent.
- Returns:
- the fill state of cache (bounds 0..1)
-
clear
public void clear()Remove all elements from the cache.
-
isEmpty
public boolean isEmpty()Check if the cache is empty.
- Returns:
- true if the cache is empty
-
setCacheSize
Set the expected size of the cache.
- Parameters:
index- index of the cache to be setvalue- the new size of the specified cache- Throws:
IOException- if the index is not known to the cache
-
removeCacheElement
Remove the specified key type from cache.
- Parameters:
index- the index of the cache to be removed- Throws:
IOException- if the index does not belong to a known element
-
showStats
public void showStats()Dumps cache stats to the logger.
-