Class DirectConnectionDemandsCache
- java.lang.Object
-
- org.drasyl.peer.connection.direct.DirectConnectionDemandsCache
-
public class DirectConnectionDemandsCache extends Object
This class caches all peers for a direct connection has been demanded. This cache deletes all entries automatically after the time specified inexpireTime
. This class thus can be used to track currently demanded direct connections.
-
-
Constructor Summary
Constructors Constructor Description DirectConnectionDemandsCache(int maximumSize, Duration expireTime)
Creates a new cache which automatically removes any entry after the duration specified inexpireTime
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(CompressedPublicKey publicKey)
AddspublicKey
to the cache.void
clear()
Clears the cache.boolean
contains(CompressedPublicKey publicKey)
-
-
-
Constructor Detail
-
DirectConnectionDemandsCache
public DirectConnectionDemandsCache(int maximumSize, Duration expireTime)
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 Detail
-
add
public void add(CompressedPublicKey publicKey)
AddspublicKey
to the cache.- Parameters:
publicKey
- public key to be added
-
contains
public boolean contains(CompressedPublicKey publicKey)
- 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.
-
-