public class AsymmetricKeyCache extends Object implements Serializable
The key cache supporting AsymmetricKey.
Modifier and Type | Field and Description |
---|---|
static SecureRandom |
esr |
static long |
serialVersionUID |
Constructor and Description |
---|
AsymmetricKeyCache() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all elements from the cache.
|
double |
getCacheFillGrade()
Get the total cache fill grade in percent.
|
double |
getLowestCacheSize()
Get the size of the lowest cache in fraction of percent.
|
AlgorithmParameter |
getSpeculativeParameter()
Gets a set of parameter which should be calculated next.
|
boolean |
isEmpty()
Check if the cache is empty.
|
void |
load(String filename)
Loads the cache from the specified filename.
|
void |
merge(String filename)
Adds the keys in the specified file to the cache.
|
AsymmetricKey |
peek(AlgorithmParameter parameter)
Gets a precalculated key from the cache without removing it.
|
AsymmetricKey |
pull(AlgorithmParameter parameter)
Gets a precalculated key from the cache.
|
void |
push(AsymmetricKey key)
store a precalculated key into the cache.
|
void |
removeCacheElement(int index)
Remove the specified key type from cache.
|
void |
requestCacheIncrease(AlgorithmParameter parameter)
Increase the cache size for the specified parameter set.
|
void |
setCacheSize(int index,
int value)
Set the expected size of the cache.
|
void |
setCalcTime(AlgorithmParameter ap,
long millis)
Sets the time for a calculation with the specified parameter.
|
void |
showStats()
Dumps cache stats to the logger.
|
void |
store(String filename)
Stores the cache to the specified filename for later usage.
|
public static final long serialVersionUID
public static final SecureRandom esr
public void store(String filename) throws IOException
Stores the cache to the specified filename for later usage.
filename
- the filename to store to (will replace an existing file)IOException
- if writing of file failspublic void load(String filename) throws IOException
Loads the cache from the specified filename.
filename
- the filename to read fromIOException
- if reading of file failspublic void merge(String filename) throws IOException
Adds the keys in the specified file to the cache.
filename
- the filename of the cache to mergeIOException
- if reading of the file failspublic void setCalcTime(AlgorithmParameter ap, long millis)
Sets the time for a calculation with the specified parameter.
ap
- parameter setmillis
- the time in milliseconds it takes on average to calculate the keypublic AsymmetricKey pull(AlgorithmParameter parameter)
Gets a precalculated key from the cache.
parameter
- the parameter set requestedpublic AsymmetricKey peek(AlgorithmParameter parameter)
Gets a precalculated key from the cache without removing it.
parameter
- the parameter set requestedpublic void push(AsymmetricKey key)
store a precalculated key into the cache.
key
- the key to be storedpublic void requestCacheIncrease(AlgorithmParameter parameter)
Increase the cache size for the specified parameter set.
parameter
- the parameter set to be increasedpublic AlgorithmParameter getSpeculativeParameter()
Gets a set of parameter which should be calculated next.
public double getLowestCacheSize()
Get the size of the lowest cache in fraction of percent.
public double getCacheFillGrade()
Get the total cache fill grade in percent.
public void clear()
Remove all elements from the cache.
public boolean isEmpty()
Check if the cache is empty.
public void setCacheSize(int index, int value) throws IOException
Set the expected size of the cache.
index
- index of the cache to be setvalue
- the new size of the specified cacheIOException
- if the index is not known to the cachepublic void removeCacheElement(int index) throws IOException
Remove the specified key type from cache.
index
- the index of the cache to be removedIOException
- if the index does not belong to a known elementpublic void showStats()
Dumps cache stats to the logger.
Copyright © 2023. All rights reserved.