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 in expireTime. This class thus ensures that the same peer is not asked for information too frequently.
  • Constructor Details

    • RequestPeerInformationCache

      public RequestPeerInformationCache(int maximumSize, Duration expireTime)
      Creates a new cache which automatically removes any entry after the duration specified in expireTime. The cache can contain maximum of maximumSize entries. Evicts oldest entries if limit is exceeded.
      Parameters:
      maximumSize - maximum number of entries cache can contain
      expireTime - time after newly added entries will be automatically removed
  • Method Details

    • add

      public boolean add(CompressedPublicKey publicKey)
      Adds publicKey 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, otherwise false is returned