Class DirectConnectionDemandsCache
java.lang.Object
org.drasyl.peer.connection.direct.DirectConnectionDemandsCache
This class caches all peers for a direct connection has been demanded. This cache deletes all
entries automatically after the time specified in
expireTime. This class thus can be
used to track currently demanded direct connections.-
Constructor Summary
ConstructorsConstructorDescriptionDirectConnectionDemandsCache(int maximumSize, Duration expireTime) Creates a new cache which automatically removes any entry after the duration specified inexpireTime. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(CompressedPublicKey publicKey) AddspublicKeyto the cache.voidclear()Clears the cache.booleancontains(CompressedPublicKey publicKey)
-
Constructor Details
-
DirectConnectionDemandsCache
Creates a new cache which automatically removes any entry after the duration specified inexpireTime. The cache can contain maximum ofmaximumSizeentries. 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
AddspublicKeyto the cache.- Parameters:
publicKey- public key to be added
-
contains
- Parameters:
publicKey- the public key to be checked- Returns:
true, ifpublicKeyis contained in cache. Otherwisefalseis returned
-
clear
public void clear()Clears the cache.
-