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 TypeMethodDescriptionvoid
add
(CompressedPublicKey publicKey) AddspublicKey
to the cache.void
clear()
Clears the cache.boolean
contains
(CompressedPublicKey publicKey)
-
Constructor Details
-
DirectConnectionDemandsCache
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.- Parameters:
publicKey
- public key to be added
-
contains
- Parameters:
publicKey
- the public key to be checked- Returns:
true
, ifpublicKey
is contained in cache. Otherwisefalse
is returned
-
clear
public void clear()Clears the cache.
-