Class RequestPeerInformationCache
- java.lang.Object
-
- org.drasyl.peer.connection.direct.RequestPeerInformationCache
-
public class RequestPeerInformationCache extends Object
This class caches all peers for which information has been requested. This cache deletes all entries automatically after the time specified inexpireTime
. This class thus ensures that the same peer is not asked for information too frequently.
-
-
Constructor Summary
Constructors Constructor Description RequestPeerInformationCache(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 boolean
add(CompressedPublicKey publicKey)
AddspublicKey
to the cache if it is not already cached.
-
-
-
Constructor Detail
-
RequestPeerInformationCache
public RequestPeerInformationCache(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 boolean add(CompressedPublicKey publicKey)
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
-
-