Class InMemoryCertificateCache
- Namespace
- SimpleSign.Core.Crypto
- Assembly
- SimpleSign.Core.dll
In-memory certificate cache with configurable TTL (time-to-live). Thread-safe for concurrent reads and writes.
public sealed class InMemoryCertificateCache : ICertificateCache
- Inheritance
-
InMemoryCertificateCache
- Implements
- Inherited Members
Constructors
InMemoryCertificateCache(TimeSpan?)
Creates a new in-memory certificate cache.
public InMemoryCertificateCache(TimeSpan? ttl = null)
Parameters
ttlTimeSpan?Time-to-live for cached entries. Default: 1 hour.
Properties
Count
Number of certificates currently cached.
public int Count { get; }
Property Value
Methods
Clear()
Removes all entries from the cache.
public void Clear()
Evict()
Removes expired entries from the cache. Call periodically in long-running applications to free memory.
public int Evict()
Returns
- int
Number of entries removed.
Set(X509Certificate2)
Adds or updates a certificate in the cache.
public void Set(X509Certificate2 certificate)
Parameters
certificateX509Certificate2The certificate to cache.
TryGet(string, out X509Certificate2?)
Attempts to retrieve a certificate by its SHA-256 thumbprint.
public bool TryGet(string thumbprint, out X509Certificate2? certificate)
Parameters
thumbprintstringSHA-256 thumbprint (hex, uppercase).
certificateX509Certificate2The cached certificate, or null.
Returns
- bool
True if found in cache.