APIPublic key cache

Public key cache

Keeps recently used public keys in memory. A public key cache is used for message processing.

Instance creation

PublicKeyCache publicKeyCache = new PublicKeyCache(1024);
var publicKeyCache = new cn.PublicKeyCache(1024);
my $publicKeyCache = CN::PublicKeyCache->new(1024);

Creates an empty cache with space for 1024 public keys.

Cache access

publicKeyCache.add(publicKey);
publicKeyCache.add(publicKey);
$publicKeyCache->add($publicKey);

Adds a public key to the cache. If the

PublicKey publicKey = publicKeyCache.get(hash);
var publicKey = publicKeyCache.get(hash);
my $publicKey = $publicKeyCache->get($hash);

Retrieves a public key from the cache. If the corresponding key is not in the cache, the function returns nullundef.

Cleanup

publicKeyCache.cleanup(10 * Duration.MINUTE);
publicKeyCache.cleanup(10 * cn.MINUTE);
$publicKeyCache->cleanup(10 * CN->MINUTE);

Removes all entries from the cache that have not been accessed for more than 10 minutes.