package memory import ( "sync" cache "forge.cadoles.com/cadoles/bouncer/internal/cache" ) type Cache[K comparable, V any] struct { store *sync.Map } // Get implements cache.Cache. func (c *Cache[K, V]) Get(key K) (V, bool) { raw, exists := c.store.Load(key) if !exists { return *new(V), false } return raw.(V), exists } // Set implements cache.Cache. func (c *Cache[K, V]) Set(key K, value V) { c.store.Store(key, value) } func NewCache[K comparable, V any]() *Cache[K, V] { return &Cache[K, V]{ store: new(sync.Map), } } var _ cache.Cache[string, bool] = &Cache[string, bool]{}