Class RequestPeerInformationCache
java.lang.Object
org.drasyl.peer.connection.direct.RequestPeerInformationCache
This class caches all peers for which information has been requested. This cache deletes all
entries automatically after the time specified in
expireTime
. This class thus
ensures that the same peer is not asked for information too frequently.-
Constructor Summary
ConstructorsConstructorDescriptionRequestPeerInformationCache
(int maximumSize, Duration expireTime) Creates a new cache which automatically removes any entry after the duration specified inexpireTime
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(CompressedPublicKey publicKey) AddspublicKey
to the cache if it is not already cached.
-
Constructor Details
-
RequestPeerInformationCache
Creates a new cache which automatically removes any entry after the duration specified inexpireTime
. The cache can contain maximum ofmaximumSize
entries. Evicts oldest entries if limit is exceeded.- Parameters:
maximumSize
- maximum number of entries cache can containexpireTime
- time after newly added entries will be automatically removed
-
-
Method Details
-
add
AddspublicKey
to the cache if it is not already cached.- Parameters:
publicKey
- the public key that should be added- Returns:
true
if the key was not already cached, otherwisefalse
is returned
-