new CertificateCacheV2(maxLifetimeMilliseconds)
A CertificateCacheV2 holds other user's verified certificates in security v2
format CertificateV2. A certificate is removed no later than its NotAfter
time, or maxLifetime after it has been added to the cache.
Create a CertificateCacheV2.
Parameters:
Name | Type | Description |
---|---|---|
maxLifetimeMilliseconds |
number | (optional) The maximum time that certificates can live inside the cache, in milliseconds. If omitted, use getDefaultLifetime(). |
Methods
clear()
Clear all certificates from the cache.
deleteCertificate(certificateName)
Remove the certificate whose name equals the given name. If no such
certificate is in the cache, do nothing.
Parameters:
Name | Type | Description |
---|---|---|
certificateName |
Name | The name of the certificate. |
find(prefixOrInterest) → {CertificateV2}
Find the certificate by the given prefix or interest.
Parameters:
Name | Type | Description |
---|---|---|
prefixOrInterest |
Name | Interest | If a Name, return the first certificate (ordered by name) where the Name is a prefix of the certificate name. If an Interest, return the first certificate (ordered by Name) where interest.matchesData(certificate) . |
Returns:
The found certificate, or null if not found. You
must not modify the returned object. If you need to modify it, then make a
copy.
- Type
- CertificateV2
findFirstByName_(name) → {number}
A private helper method to get the first entry in certificatesByName_ whose
name is greater than or equal to the given name.
Parameters:
Name | Type | Description |
---|---|---|
name |
Name | The name to search for. |
Returns:
The index of the found certificatesByName_ entry, or -1 if
not found.
- Type
- number
insert(certificate)
Insert the certificate into the cache. The inserted certificate will be
removed no later than its NotAfter time, or maxLifetimeMilliseconds given to
the constructor.
Parameters:
Name | Type | Description |
---|---|---|
certificate |
CertificateV2 | The certificate object, which is copied. |
refresh_()
Remove all outdated certificate entries.
setNowOffsetMilliseconds_(nowOffsetMilliseconds)
Set the offset when insert() and refresh_() get the current time, which
should only be used for testing.
Parameters:
Name | Type | Description |
---|---|---|
nowOffsetMilliseconds |
number | The offset in milliseconds. |
(static) getDefaultLifetime() → {number}
Get the default maximum lifetime (1 hour).
Returns:
The lifetime in milliseconds.
- Type
- number