feat: Add Support for Proxy with Interceptor (#77)

This commit is contained in:
Abhisek Datta
2025-12-10 08:34:28 +05:30
committed by GitHub
parent a8723cd680
commit 21eb05373f
15 changed files with 1852 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
package certmanager
import "sync"
// InMemoryCache implements CertificateCache using an in-memory map
type InMemoryCache struct {
mu sync.RWMutex
cache map[string]*Certificate
}
// NewInMemoryCache creates a new in-memory certificate cache
func NewInMemoryCache() *InMemoryCache {
return &InMemoryCache{
cache: make(map[string]*Certificate),
}
}
func (c *InMemoryCache) Get(hostname string) (*Certificate, bool) {
c.mu.RLock()
defer c.mu.RUnlock()
cert, found := c.cache[hostname]
return cert, found
}
func (c *InMemoryCache) Set(hostname string, cert *Certificate) {
c.mu.Lock()
defer c.mu.Unlock()
c.cache[hostname] = cert
}
func (c *InMemoryCache) Clear() {
c.mu.Lock()
defer c.mu.Unlock()
c.cache = make(map[string]*Certificate)
}
func (c *InMemoryCache) Size() int {
c.mu.RLock()
defer c.mu.RUnlock()
return len(c.cache)
}